Skip to content

Instantly share code, notes, and snippets.

@wliao008
Created March 26, 2015 13:21
Show Gist options
  • Save wliao008/cb0b301da18293c3075d to your computer and use it in GitHub Desktop.
Save wliao008/cb0b301da18293c3075d to your computer and use it in GitHub Desktop.
Blinking On-Board LED
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