How to compare a string coming from serial monitor with some predefined text stored as a local variable? If I say:
int led = 2;
String a = " abcds";
void setup(){
Serial.begin(9600);
}
void loop() {
String b = Serial.read();
Serial.println(b);
if (b != a) {
digitalWrite(2,LOW);
}
else
{
digitalWrite(2,HIGH);
}
}
just as an example, this code will not compile because on the serial I receive bytes and I want to compare with a string. So my question is... how should be done?