I'm working on a system that is making use serial communications (via the serial interface) the board I am using is a Mega2560 R3 it appears to be sticking in extra CR & LF's that can only be due the system using Serial.println(""). Anyone seen this... I was going to ignor it but this is sort of thing that can be awkard.
if(digitalRead(col_1)==0)
{
Serial.println("key 1 pressed");
}
else if(digitalRead(col_2)==0)
{
Serial.println("Key 2 pressed");
}
else if(digitalRead(col_3)==0)
{
Serial.println("Key 3 pressed");
}
all the print statements use println() if this was the case, causing this I would expect a CR&LF as all the digits use this...
"Use print instead of println if you don't want the CR & LF. That's what println is supposed to do is add those. "
I was using println as I want a CR & LF, it seems that some times an extra CR & LF gets added to the string.
Could there be an extra inserted by the USB connection, I wonder...
Only posting a snippet of your code is problematic because we can't check whether there are other prints elsewhere that might cause the output you're getting.