Created
July 24, 2018 14:58
-
-
Save trevorgreenleaf/969da39d71970e5db998f51584746fe7 to your computer and use it in GitHub Desktop.
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
int led1 = D0; | |
// the little blue LED on your board | |
int led2 = D7; | |
// when the device starts up it will run the setup function or when the device is reset | |
// void meaning it is not going to return a value | |
void setup() { | |
// We are going to tell our device that D0 and D7 (which we named led1 and led2 respectively) are going to be output | |
// (That means that we will be sending voltage to them, rather than monitoring voltage that comes from them) | |
// It's important you do this here, inside the setup() function rather than outside it or in the loop function. | |
pinMode(led1, OUTPUT); | |
pinMode(led2, OUTPUT); | |
// register the cloud function | |
Particle.function("light", lightIt); | |
} | |
// this function automagically gets called upon a matching POST request | |
int lightIt(String command) { | |
if(command == "on"){ | |
digitalWrite(led1, HIGH); | |
// some example functions you might have | |
// activateWaterHeater(); | |
// activateWaterPump(); | |
} | |
if(command == "off"){ | |
digitalWrite(led1, LOW); | |
} | |
} | |
void loop() { | |
// To blink the LED, first we'll turn it on... | |
// digitalWrite(led1, HIGH); | |
// digitalWrite(led2, HIGH); | |
// // We'll leave it on for 1 second... | |
// delay(6000); | |
// // Then we'll turn it off... | |
// digitalWrite(led1, LOW); | |
// digitalWrite(led2, LOW); | |
// // Wait 1 second... | |
// delay(1000); | |
// And repeat! | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment