Skip to content

Instantly share code, notes, and snippets.

@surinoel
Created July 8, 2019 03:35
Show Gist options
  • Save surinoel/7def241800109a00ddf7dbd13d047b11 to your computer and use it in GitHub Desktop.
Save surinoel/7def241800109a00ddf7dbd13d047b11 to your computer and use it in GitHub Desktop.
int pinLED = 13;
int ledStatus = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(pinLED, OUTPUT);
Serial.println("usage : write (turn on | turn off)");
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(pinLED, ledStatus);
while(Serial.available() > 0) {
if(Serial.find("turn on")) {
Serial.println("turn on");
ledStatus = 1;
}
else if(Serial.find("turn off")) {
Serial.println("turn off");
ledStatus = 0;
}
else {
Serial.println("usage : write (turn on | turn off)");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment