Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clearing the terminal screen?

I'm reading data from 9 different sensors for my robot and I need to display them all steadily, in the same window so I can compare the values and see if any of the readings is off.

The problem I'm having with both Serial.print and lcd.print is that the values are constantly moving and I can't really have a good look at them while moving the robot.

I was thinking to call something like Serial.clear() before displaying anything else and that would just keep things steady and in one place, changing only the values.

From what I found so far, Serial.print(17,BYTE) for instance is no longer supported (Calling the ESC key).

So...for those with a bit more Arduino experience...what is the proper way to do this?

like image 783
Eugen Avatar asked Apr 11 '12 12:04

Eugen


People also ask

How do I clear the terminal screen in bash?

When using the bash shell, you can also clear the screen by pressing Ctrl + L .

How do you clear the terminal screen in C++?

To clear the screen in Visual C++, utilize the code: system("CLS"); The standard library header file <stdlib. h> is needed.


1 Answers

The Arduino serial monitor isn't a regular terminal so its not possible to clear the screen using standard terminal commands. I suggest using an actual terminal emulator, like Putty.

The command for clearing a terminal screen is ESC[2J

To accomplish in Arduino code:

  Serial.write(27);       // ESC command
  Serial.print("[2J");    // clear screen command
  Serial.write(27);
  Serial.print("[H");     // cursor to home command

Source:
http://www.instructables.com/id/A-Wirelessly-Controlled-Arduino-Powered-Message-B/step6/Useful-Code-Explained-Clearing-a-Serial-Terminal/

like image 135
jjz Avatar answered Sep 17 '22 17:09

jjz