Check for a null character.
You can initialize strings also; be sure to test code as well for valid data. Prefix each with a character.
See example below.
Thanks a lot , I could not use “match” but I got it to work.
while (BTPort.available() > 0) {
IncomingStr = BTPort.readStringUntil(lf);
if (IncomingStr != null) {
First = IncomingStr.charAt(0);
println(IncomingStr);
println(First);
if (First == 'M')
Incoming_Currents = IncomingStr; // incoming current string from teensy
else
Incoming_Info= IncomingStr; // incoming current string from teensy
}
}
The essential part was if (IncomingStr != null).
I was under the impression that the string stays at the last value till the next transmission, but it goes to Null instead.
During null, my if else functions did not work.