Created
November 15, 2011 11:30
-
-
Save mactkg/1366851 to your computer and use it in GitHub Desktop.
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
#define LED 13 | |
#define BUTTON 7 | |
int val; | |
int old_val; | |
int light; | |
void setup(){ | |
pinMode(LED, OUTPUT); | |
pinMode(BUTTON, INPUT); | |
} | |
void loop(){ | |
old_val = val; | |
val = digitalRead(BUTTON); | |
if(old_val != val){ | |
if(val == HIGH){ | |
if(light == HIGH){ | |
digitalWrite(LED, LOW); | |
light = LOW; | |
}else{ | |
digitalWrite(LED, HIGH); | |
light = HIGH; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment