I'm using an Arduino MegeMega 2560 and writing a really simple piece of code that doens'tdoesn't work.
#define led 13
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
pinMode(led, OUTPUT);
}
void loop() {
while(Serial.available()) {
letra= Serial.readStringUntil('\n');
letra.trim();
Serial.println(letra);
if(letra.equals("aa\r\n")){
Serial.println("ABRE 1");
}
if(letra == "aa\r\n"){
Serial.println("ABRE 2");
}
if(letra.compareTo("aa\r\n") == 0){
Serial.println("ABRE 3");
}
}
}```[![enter image description here][1]][1]
It's returning what I typed, but it's not entering any of the if conditions...
Can someone help me with that ?
[1]: https://i.sstatic.net/rbpI0.png
String a, letra;
#define led 13
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
pinMode(led, OUTPUT);
}
void loop() {
while(Serial.available()) {
letra= Serial.readStringUntil('\n');
letra.trim();
Serial.println(letra);
if(letra.equals("aa\r\n")){
Serial.println("ABRE 1");
}
if(letra == "aa\r\n"){
Serial.println("ABRE 2");
}
if(letra.compareTo("aa\r\n") == 0){
Serial.println("ABRE 3");
}
}
}
It's returning what I typed, but it's not entering any of the if conditions... Can someone help me with that ?
