Skip to content

Instantly share code, notes, and snippets.

@upsilun
Created July 10, 2022 19:45
Show Gist options
  • Save upsilun/fa47c6741f1745a851c7e1a0d0320d7b to your computer and use it in GitHub Desktop.
Save upsilun/fa47c6741f1745a851c7e1a0d0320d7b to your computer and use it in GitHub Desktop.
void setup()
{
pinMode(13, OUTPUT);
Serial.begin(9600);
while (!Serial);
Serial.println("Input 1 to Turn LED on and 2 to off");
}
void loop() {
if (Serial.available())
{
int state = Serial.parseInt();
if (state == 1)
{
digitalWrite(13, HIGH);
Serial.println("Command completed LED turned ON");
}
if (state == 2)
{
digitalWrite(13, LOW);
Serial.println("Command completed LED turned OFF");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment