void setup() {
Serial.begin(9600);
pinMode(LED_BUILTIN, OUTPUT); // set the digital pin as output:
}
void loop() {
if(Serial.available()) // if there is data comming
{
String command = Serial.readStringUntil('\n'); // read string until meet newline character
if(command == "ON"){
digitalWrite(LED_BUILTIN, HIGH); // turn on command
Serial.println("Turned ON"); // send action to Serial Monitor
}
else if(command == "OFF"){
digitalWrite(LED_BUILTIN, LOW); // turn off command
Serial.println("Turned OFF"); // send action to Serial Monitor
}
}
}