Last active
October 2, 2017 05:42
-
-
Save runemadsen/8d92bf788f648ed1c28d9767d241ad09 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
boolean ledState = false; | |
int lastButtonState = 0; | |
void setup() { | |
pinMode(4, INPUT); | |
pinMode(7, OUTPUT); | |
Serial.begin(9600); | |
} | |
void loop() { | |
int buttonState = digitalRead(4); | |
if (lastButtonState != buttonState && buttonState == 1) { | |
ledState = !ledState; | |
} | |
lastButtonState = buttonState; | |
if (ledState) { | |
digitalWrite(7,HIGH); | |
} else { | |
digitalWrite(7,LOW); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment