Spencer FoglemanJared Thomas
Published © GPL3+

Optical Doorbell

This project details the process of linking two Particle Photons to make a visual doorbell.

EasyFull instructions provided10 hours135
Optical Doorbell

Things used in this project

Story

Read more

Schematics

Off

The doorbell is off and inactive.
Off cfkllxhkm9

Circuit Diagrams

Circuits wdhvy2frk6

On

The doorbell is on and active.
On jf2bdw3drz

Code

Doorbell Photon

C/C++
int out = A0;
int in = A1;
int light = D7;

void setup() {
pinMode(light, OUTPUT);
digitalWrite(light, LOW);
pinMode(out, OUTPUT);
digitalWrite(out, HIGH);
pinMode(in, INPUT);
Particle.subscribe("Jared", Ring);
}

void loop() {
   int switchstate = digitalRead(in);
   if (switchstate == HIGH) {
       Particle.publish("Spencer", "DING DONG");
       delay(1000);
   }
   else if (switchstate==LOW) {
       Particle.publish("Spencer", "SILENCE");
       delay(1000);
   }
}

void Ring(const char *event, const char *data) {

if (strcmp(data, "HELLO")==0) {
    digitalWrite(light, HIGH);
}
else if (strcmp(data, "GOODBYE")==0) {
    digitalWrite(light, LOW);
}
}

Receiver Photon

C/C++
void setup() {
    pinMode(D7,OUTPUT);
    Particle.subscribe("Spencer",Ring);

}
void Ring(const char *event, const char *data)
{
    if(strcmp(data,"DING DONG")==0){
        digitalWrite(D7, HIGH);
        Particle.publish("Jared", "HELLO");
        delay(1000);
    }
    else if(strcmp(data, "SILENCE")==0){
        digitalWrite(D7,LOW);
        Particle.publish("Jared", "GOODBYE");
        delay(1000);
    }

}

Credits

Spencer Fogleman

Spencer Fogleman

1 project • 0 followers
Jared Thomas

Jared Thomas

1 project • 0 followers

Comments

Add projectSign up / Login