Peter Sprenger
Published © GPL3+

Drawer light detector

Device that lets you know if someone has gone into your drawer by using a photoresistor that sends data to another argon device.

IntermediateFull instructions provided4 hours293
Drawer light detector

Things used in this project

Hardware components

Breadboard (generic)
Breadboard (generic)
×2
Argon
Particle Argon
×2
Jumper wires (generic)
Jumper wires (generic)
×1
LED (generic)
LED (generic)
×1
Photo resistor
Photo resistor
×1
Resistor 10k ohm
Resistor 10k ohm
×2
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×2

Hand tools and fabrication machines

Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires
Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires

Story

Read more

Schematics

Circuit Diagram

Code

Code

C/C++
int led1 = A5;
int led2 = D7;
double analogValue_dbl;
int photoresistor = A0;
float analogValue; 

void setup()  {

    pinMode(led1, OUTPUT);
    pinMode(led2, OUTPUT);
    pinMode(photoresistor, INPUT);

}

void loop() {
    analogValue = analogRead(photoresistor);


    if (analogValue < 8) {
        digitalWrite(led1, LOW);
        digitalWrite(led2, LOW);
    } else {
        digitalWrite(led1, HIGH);
        digitalWrite(led2, HIGH);

analogValue_dbl = analogValue;


Particle.publish("toggle-led", PRIVATE);
    }
}

Code-2

C/C++
The coding for the receiving particle argon
void setup() {
    pinMode(D7, OUTPUT);
    Particle.subscribe("toggle-led", toggleLed, MY_DEVICES);
}

void loop() {

}

void toggleLed(const char *event, const char *data) {
    digitalWrite(D7, HIGH);
    delay(3000);
    digitalWrite(D7, LOW);
    delay(1000);

Credits

Peter Sprenger
1 project • 1 follower
Contact
Thanks to Brandon Martin.

Comments

Please log in or sign up to comment.