Skip to content

Instantly share code, notes, and snippets.

@peow2373
Created March 11, 2020 06:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peow2373/51e27c726dcabe73c5d59603e4a928b5 to your computer and use it in GitHub Desktop.
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
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