Created
March 11, 2020 06:23
-
-
Save peow2373/51e27c726dcabe73c5d59603e4a928b5 to your computer and use it in GitHub Desktop.
Checks the serial monitor for incoming values to signal whether to turn an LED on or off
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
int LEDpin = 4; | |
int incomingByte; | |
void setup() { | |
pinMode(LEDpin, OUTPUT); | |
Serial.begin(9600); | |
} | |
void loop() { | |
if (Serial.available() > 0) { | |
incomingByte = Serial.read(); | |
if (incomingByte == 'H') { | |
digitalWrite(LEDpin, HIGH); | |
} else { | |
digitalWrite(LEDpin, LOW); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment