Created
March 26, 2015 13:21
-
-
Save wliao008/cb0b301da18293c3075d to your computer and use it in GitHub Desktop.
Blinking On-Board LED
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 led = D7; | |
void setup() | |
{ | |
Spark.function("led", ledControl); | |
pinMode(led, OUTPUT); | |
digitalWrite(led, LOW); | |
} | |
void loop() | |
{ | |
} | |
int ledControl(String command) | |
{ | |
int state = 0; | |
// find out the state of the led | |
if(command == "HIGH") state = 1; | |
else if(command == "LOW") state = 0; | |
else return -1; | |
// write to the appropriate pin | |
digitalWrite(led, state); | |
return 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment