const int led1 = 2;
const int led2 = 3;
const int led3 = 4;
void setup() {
Serial.begin(9600);
Serial.println("Enter command");
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
}
void loop() {
if (Serial.available() > 0) {
String command = Serial.readString() ;
command.trim();
if (command == "L1_ON") {
digitalWrite(led1, HIGH);
}
else if (command == "L1_OFF") {
digitalWrite(led1, LOW);
}
else if (command == "L2_ON") {
digitalWrite(led2, HIGH);
}
else if (command == "L2_OFF") {
digitalWrite(led2, LOW);
}
else if (command == "L3_ON") {
digitalWrite(led3, HIGH);
}
else if (command == "L3_OFF") {
digitalWrite(led3, LOW);
}
else {
Serial.println("Typing error");
}
}
}