Created
May 20, 2016 22:02
-
-
Save kasperhartwich/512a8d2ac4f7354fede70391ee51df3a to your computer and use it in GitHub Desktop.
Small program to trigger a IFTTT event with a button on a Particle.io Photon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Simple doorbell to IFTTT program for Particle.io Photon | |
* - Connect the button to GND and D0. | |
* - Connect your particle.io account to IFTTT and setup a trigger for 'ring' | |
*/ | |
int button = D0; | |
void setup() { | |
pinMode(button, INPUT_PULLUP); | |
RGB.control(true); | |
} | |
void loop() { | |
if (digitalRead(button)==LOW) { | |
Particle.publish("ring"); //publish event aka. trigger IFTTT | |
while (digitalRead(button)==LOW) { // Wait for bellringer to let go of the doorbell | |
RGB.color(0, 0, 255); //LED to blue | |
delay(100); | |
} | |
RGB.color(0, 255, 0); //LED to green | |
delay(2000); | |
} else { | |
//Awaiting someone to ring the door | |
RGB.color(255, 0, 0); //LED to red | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment