Skip to content

Instantly share code, notes, and snippets.

@mactkg
Created November 15, 2011 11:30
Show Gist options
  • Save mactkg/1366851 to your computer and use it in GitHub Desktop.
Save mactkg/1366851 to your computer and use it in GitHub Desktop.
#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