Created
June 6, 2018 01:20
-
-
Save gallaugher/9894fdfb826fece2e034767f9aedb8e0 to your computer and use it in GitHub Desktop.
TXPlore Day 12, Learning By Doing 5 - BONUS Switch Case
This file contains 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
byte BUTTON_PIN = 7; | |
byte LED_PIN = 6; | |
byte buttonState = 0; | |
void setup() { | |
// put your setup code here, to run once: | |
pinMode(BUTTON_PIN, INPUT); | |
pinMode(LED_PIN, OUTPUT); | |
Serial.begin(9600); | |
} | |
void loop() { | |
// put your main code here, to run repeatedly: | |
switch (digitalRead(BUTTON_PIN)) { | |
case HIGH: | |
digitalWrite(LED_PIN, HIGH); | |
break; | |
case LOW: | |
digitalWrite(LED_PIN, LOW); | |
break; | |
default: | |
// shouldn't be here | |
Serial.println("ERROR: BUTTON_PIN was neither high nor low"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment