I have this code below where I got from this forum that I followed through. It did not work for me but they claim that the code is fine. I already tried several string compariso
Why not use Serial.readString();??
Try this..
void setup() { pinMode(13, OUTPUT); Serial.begin(9600); } void loop(){ if(Serial.available()){ String ch; ch = Serial.readString(); ch.trim(); if(ch=="on"||ch=="ON"){ digitalWrite(13, HIGH); } else if(ch=="off"||ch=="OFF"){ digitalWrite(13, LOW); } } }