Serial port prints on one line! How to solve?

Hey Arduino Forum! I’ve been trying to fix a problem were the Serial Monitor keeps on writing on the same line. I tried to fix the settings (No line ending, New line etc…) at the bottom but nothing helps. Is it caus of the code? Please HELP!

Screen Shot 2012-09-02 at 7.56.34 PM.png

Well perhaps you could try using:

Serial.println(reading); instead of Serial.print(reading);

Lefty

retrolefty: Well perhaps you could try using:

Serial.println(reading); instead of Serial.print(reading);

Lefty

Thanks for the post, exactly what I needed! :)

alternative is the use of \n

Serial.print(“first line\n second line\n”);

Besides \n the \t (tab is also interesting as it allows to columnize numbers and text in the output (copy to Excel is a breeze;).

snippet

void loop()
{
   Serial.print(millis());
   Serial.print("\t");
   Serial.print(analogRead(A0));
   Serial.print("\t");
   Serial.print(analogRead(A1));
   Serial.print("\t");
   Serial.print(analogRead(A2));
   Serial.print("\n");
}

robtillaart: alternative is the use of \n

Serial.print("first line\n second line\n");

Besides \n the \t (tab is also interesting as it allows to columnize numbers and text in the output (copy to Excel is a breeze;).

Thanks robtillaart! In fact I was doing a temperature logging project a while ago and I couldn't understand what "/n" means in other people's code examples. I worked with Excel as well in my project so your comment is very useful to me. I didn't know nothing about "\t" at all, I always was searching for something similar to it. Appreciate your help!

I prefer the \t (tab) as separator as it also formats the output nice in the serial port monitor. Further more dependant on the locale the comma is a decimal separator in floating point numbers (e.g. in Dutch Excel it is) which causes problems.

If you have more questions, just ask ! - but first search the forum as it contains already a zillion answers ;)