Created
June 24, 2013 03:23
-
-
Save jonathanhculver/5847574 to your computer and use it in GitHub Desktop.
/* changes the light or reports its status */
This file contains hidden or 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
| /* 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