Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Celeste TietzTara Newman
Published

Disturb At A Distance (DAAD)

Someone laying around or not waking up? Disturb at a Distance gets them to get up and start moving!

BeginnerFull instructions provided2 hours673
Disturb At A Distance (DAAD)

Things used in this project

Story

Read more

Schematics

Buzzer Photon

This is the circuit that connects one Photon to a buzzer.
The photon can be plugged into any outlet using the provided USB.

Button Photon

This is the circuit that contains the second photon and the shutoff button.
The photon can be plugged into an outlet using the provided USB.
The resistor is 1000 Ohms.

Code

Buzzer Photon Code

C/C++
This is the code for the photon connected to the buzzer.
It was written on build.particle.io
int buzzer = D3;
int led = D7;


void setup()
{                
    pinMode(buzzer, OUTPUT);  // buzzer on pin D3
    pinMode(led, OUTPUT);
    digitalWrite(buzzer, LOW);
    digitalWrite(led, LOW);
    
    Particle.subscribe("BuzzerState", BuzzBuzz );
    delay(3000);
    
    Particle.subscribe("ButtonState", AlarmOff );
    delay(3000);
 }    


 void BuzzBuzz (const char *event, const char *data)  
 {
    digitalWrite(led,HIGH);
    tone(D3, 200, 0);
    Particle.publish("AlarmState", "1");
    delay(45000);
     
 }
 
 void AlarmOff (const char *event, const char *data)   
 {
    
    digitalWrite(buzzer,LOW);
    digitalWrite(led, LOW);
    Particle.publish("AlarmState", "0");
    delay(45000);
 }

Button Photon Code

C/C++
This is the code used for the photon and the buzzer.
It was written on build.particle.io
// Our button wired to D0
int button = D0;
int led = D7;

void setup() {
    pinMode(button, INPUT); // sets pin as input
    pinMode(led, OUTPUT);
    digitalWrite(button, LOW);
    digitalWrite(led, LOW);
    delay(4000);
   
    Particle.subscribe("BuzzerState", Blinky );
    delay(3000);
    Particle.subscribe("AlarmState", BuzzerOFF );
    delay(3000);
}


void loop() {
 
  if( digitalRead(button) == HIGH )  {
    Particle.publish("ButtonState","Button Pushed");
    delay(3000);
  }
}

void Blinky (const char *event, const char *data)  {
   digitalWrite(led, HIGH);
 }

void BuzzerOFF (const char *event, const char *data) {
  if (strcmp(data,"0")==0) {
    digitalWrite(led, LOW);
    delay(6000);
  }
    else{
    }
   
 }

Credits

Celeste Tietz

Celeste Tietz

1 project • 1 follower
Mechanical Engineering Student at UNC Charlotte
Tara Newman

Tara Newman

1 project • 0 followers

Comments