Overwrite a line w/Serial.print (<CR> no <LF>)

Hi, I’m trying to get Serial.print to overwrite the same line so that the text doesn’t scroll down as I count through a counter. I’ve tried:
…in a loop…
Serial.print(“Step:”);
Serial.print(iCounter);
Serial.print(13,BYTE);
…blah blah…
expecting the 13 to do a without a linefeed, thus overwriting the previous text. But it acts as if it prints nothing. I’ve also tried ‘\r’. Any ideas? TIA

Are you using the Arduino IDE to capture and view the Serial output?

If so, I suspect the IDE doesn't support what you're trying to do.

  • Brian

Yes, I am using the Arduino serial display in the IDE. I wasn't aware of another option (that's simple...)

I haven't tried it myself but presumably you can use any terminal program to capture the output. The downside is that the IDE doesn't have any support for coordinating with the other program.

I wasn't aware of another option (that's simple...)

I'm not aware of any either.

  • Brian

I have downloaded RealTerm (from sourceforge.net) just a few hours ago for this reason. And it works like a charm displaying the text my Arduino sends using Serial.print() and Serial.println().

All have have to consider is to stop capturing serial input before uploading a new sketch (you do not need to quit the terminal program). Otherwise you would get an error message.

You might want to give it a try. And don't forget to tell us if you succeed!

  • Klaus

I tried RealTerm. Nice program with lots of options. But it still feeds a new line when I send a \r only. I tried various options but couldn't get what I want. I also am having trouble with the scrollback feature (particularly important if I can't keep the output on the same line) and I've had it hang on me. Since this is really just for debugging, I think I'll go back to the Arduino IDE - much less overhead. I'd be curious, though, if you can get RealTerm to do the single line overwrite from Aduino.

In Realterm, click the Display tab and select Ansi (the default is Ascii). This should get the cursor back to the start of the line when \r is received/

That's it! The values are displayed and change accordingly without scrolling.

Thank you for the solution!

  • Klaus

Ahhh! Works like a champ for me too. Thanks mem. I also notice that typing a character when the display is selected sends the character - a nice feature that simplifies my life. Now if I could only get scrollback to work...

Now if I could only get scrollback to work...

What version are you using, 2.0.0.66 lets you scroll when the port is closed.

Well, this is amusing. I found the beta versions page at http://www.i2cchip.com/realterm and downloaded v 2.0.0.66 (I was using 2.0.0.57 - the last stable version available on sourceforge). Sure enough, scrollback worked. But when I also try to set display=1 from the command line, I get invalid pointer operations and the whole thing bombs. (did I set it right? trying to get Ansi as the default) I decided to work backwards through releases to see if I could find one with scrollback and display working. I downloaded .65 and .61, both of which appear to behave like .66 in this regard. When I went to get .58, I could no longer load the page! Hmmm...could it be that 3 downloads in quick succession is triggering some sort of hacker protection? Ugghhh....I'll try again after rebooting....or maybe after a few hours.

I have not tried to change the defaults from the command line, but 2.0.0.66 does support both ansi and scrollback selected from the display tab