Serial.println inserting extra CR & LF

Hi All,

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.

Thank You
Glenn

What do you expect to receive ?
What do you actually receive ?

Expected:

key 4 pressed
key 4 pressed
key 1 pressed
key 1 pressed

it is connected to a 9 way keypad

key * pressed
Key 0 pressed
Key # pressed
Key # pressed

key 1 pressed
key 1 pressed
Key 2 pressed

Key 3 pressed
Key 3 pressed

key 4 pressed
key 4 pressed

Key 5 pressed
Key 5 pressed

Key 6 pressed
key 7 pressed

Key 8 pressed
Key 9 pressed

Key 9 pressed
The code behind this is

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.