Skip to content

Instantly share code, notes, and snippets.

@jonathanhculver
Created June 24, 2013 03:23
Show Gist options
  • Select an option

  • Save jonathanhculver/5847574 to your computer and use it in GitHub Desktop.

Select an option

Save jonathanhculver/5847574 to your computer and use it in GitHub Desktop.
/* changes the light or reports its status */
/* changes the light or reports its status */
String changeLight(int val) {
/* turn light on */
if(val== 1) {
digitalWrite(pin, HIGH);
lightStatus = "on";
/* turn light off */
} else if(val==0) {
digitalWrite(pin, LOW);
lightStatus = "off";
/* check current status of the light */
} else if(val==-1) {
int status = digitalRead(pin);
if(status == 0) {
lightStatus = "off";
} else if(status == 1) {
lightStatus = "on";
}
}
return lightStatus;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment