String inputCommand;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(2, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
if(Serial.available()){
inputCommand = Serial.readString();
inputCommand.trim();
inputCommand.toLowerCase();
if(inputCommand == "on") {
digitalWrite(2,HIGH);
}
else if(inputCommand == "off") {
digitalWrite(2, LOW);
}
else {
Serial.println("Invalid Command");
}
}
}