I've been messing a bit with serial communications & I'd like to match the serial.readString to a string for an if statement I now have a code, yet it keeps giving false when I type 'a' (<- without quoting) in the serial bar.
here's my code:
String a = "a";
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.setTimeout(200);
}
void loop() {
// put your main code here, to run repeatedly:
if (Serial.available() > 0) {
String command = Serial.readString();
Serial.print(command);
if (command.equals(a)) {
Serial.print("hello"); // <- need this
} else {
Serial.print("crap");
}
}
}