Last active
May 25, 2018 22:52
-
-
Save jhodges10/e2ba99acd443dee5e8eabbcb95ba8eec to your computer and use it in GitHub Desktop.
Particle Photon Dash Treasury Vote Indicator
This file contains 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
//The pin you want to control, in this case I'm blinking the on-board blue LED on digital pin D7 and an LED on pin D0 | |
int led1 = D0; | |
int led2 = D7; | |
//This function is called after the Photon has started | |
void setup(){ | |
//We set the pin mode to output | |
pinMode(led1, OUTPUT); | |
pinMode(led2, OUTPUT); | |
//We set ourselves up to listen to a function call through the Particle event handler | |
Particle.function("voteHandler", voteHandler); | |
} | |
//The program loop, not sure if this has to be here for the program to run or not | |
void loop() | |
{ | |
} | |
//The function that handles the event | |
int voteHandler(String command) | |
{ | |
// look for the matching argument "vote" <-- max of 64 characters long | |
if(command == "yesVote") { | |
// We'll turn the LED on | |
digitalWrite(led2, HIGH); | |
// We'll leave it on for 1 second... | |
delay(15000); | |
// Then we'll turn it off... | |
digitalWrite(led2, LOW); | |
return 1; | |
} | |
else if(command == "noVote") { | |
// We'll turn the LED on | |
digitalWrite(led1, HIGH); | |
// We'll leave it on for 1 second... | |
delay(15000); | |
// Then we'll turn it off... | |
digitalWrite(led1, LOW); | |
return 0; | |
} | |
else { | |
return -1; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment