Why doesn't' this work?

I can't figure this out.

First I am receiving this string over serial...

&&
01511000.00
01522000.11
01533000.22
01544000.33
01555000.44
01566000.55
!!

Each line is terminated with a CR and LF

I want to detect when the String = "&&" and parse the data for storing on a SD.

Trying this to detect the && and then print it to prove i can detect it but the if statement always evaluates as true. What is wrong with this?


void setup() {
Serial.begin(9600);
Serial1.begin(9600);

}

void loop() {

String s2;

if (Serial1.available() > 0) {
String s1 = Serial1.readStringUntil('\n');
s2 = s1;

if (s2 == "&&"); {
Serial.println(s2);
}

}
}

Remove the semicolon:

    if (s2 == "&&"); {

Print the length of the String. I suspect it contains a CR.

I corrected the error with the ;. wildbill, think your right. How do I add the CR char in to the

if (s2 == "&&") {

Line?

if (s2 == "&&\r") {

Thanks again! That worked, i didn't realise you could do that!