HOW-TO: Serial.print() to cpecific row & collu


Debugging applications I often have to monitor many parameters at once. It's very hard with Arduino built in java terminal. Output is scrolling continuously, it's almost impossible to spot anything especially when monitoring changes in values.

It is possible to output values you need to specific places of the screen.

Like x,y position. All you need is terminal application capable of displaying "Xterm" command sequences. I'm using iTerm ( for MacOS X and for Windows you have free Putty app.

The only trade off is that you have to use external program instead of pressing nice shiny button in Arduino IDE. But it pays off in terms of visibility and ease of debugging.

All you have to do is to incorporate Xterm control sequences in your code like this

void setup() {
  Serial.print("\eSP F");  // tell to use 7-bit control codes
  Serial.print("\e[?25l"); // hide cursor
  Serial.print("\e[?12l"); // disable cursor highlighting

This is all needed to tell terminal application that you will use Xterm commands. An that you don't nee pesky bold cursor running like mad across the screen when values are updating.

Now how to output text on row; column coordinates

Serial.print("\e[1;1HTank hardware test console");
sens_fRng =analogRead(fRng);
Serial.print("\e[5;1HRangefinder: \e[5;16H");

Now what does "\e[1;1H" means?
\e[- This is so called escape sequence. It tells Xterm that next text will be command.
1;1 - row and column. Just put there cursor coordinates you desire. Text will be every time outputted there.
H - I think this is positioning command itself, but I don't care.

// I'm reading my sensor  
sens_fRng =analogRead(fRng); 
// I'm putting text "Rangefiders"  at row 5, col 1. And moving cursor
// to column 16 to output next text there.
Serial.print("\e[5;1HRangefinder: \e[5;16H");
// Guess what? next text is my sensor reading value. It will be
// outputted where I told before.

So remember that you have to move cursor to position you need before outputting some text.

How to view it on computer

On MacOS X just open iTerm ( application and type there

screen /dev/name_of_your_arduino_port

My Arduino port is named tty.usbserial-A900ad3P. SO my command is screen /dev/tty.usbserial-A900ad3P

I'm sure there are many way to make this faster and more user friendly. For example Arduino Xterm library like Xterm.print("text",x,y)

And it should be possible to put and icon on your screen opening terminal application with all settings needed. I really hope this guide will be useful to some beginners struggling with lack of other means of debugging your running code as many-many variables output.

Thank you for that info !

I found that I also needed


in the setup() routine to clear the screen, otherwise I had some garbage in there.

Awesome, just what I was looking for. That scrolling screen is annoying. Hopefully it can be included at some point in the released code.

This is a VT100 (or VT52) emulation code. You can probably set the emulation mode of the iTerm. If you search for VT100 codes you will find many of them also to make values BOLD etc

void setup()

void loop()
  String OFF = "\033[0m";
  String BOLD = "\033[1m";
  Serial.println("Hello World");