Serial monitoring overriding the old values?

Hello, Is it possible to override the old values in serial monitor without keep on scrolling trough to see newer ones? This is my old currently I'm just trying to real the analog pins for test.

Joseph


void setup() {
  Serial.begin(9600);
}
void loop() {
  int sensorValue = analogRead(A0);
  Serial.println(sensorValue);
Serial.println("");
   int sensorValue2 = analogRead(A1);
  Serial.println(sensorValue2);
  
  Serial.println("");
  
   int sensorValue3 = analogRead(A2);
  Serial.println(sensorValue3);
  
  Serial.println("");
  
   int sensorValue4 = analogRead(A3);
  Serial.println(sensorValue4);
  
  Serial.println("");
  
   int sensorValue5 = analogRead(A4);
  Serial.println(sensorValue5);
  
Serial.println("");

   int sensorValue6 = analogRead(A5);
  Serial.println(sensorValue6);

    delay(1000);
}

Not with the serial monitor in the Arduino IDE. Its possible using a terminal program that supports VT100 emulation.

@david_2018 What I want to do is when I use my LCD screen. How it just display the current values and not the past values thats all.

With an LCD, just set the cursor to the appropriate position, print spaces over the old value, reposition the cursor, then print the new value. Overwriting with spaces is needed to erase any digits of the number that would be left on the LCD if the new number has less digits.

Apparently you don't understand the definition of Serial, here it is

A serial port is a serial communication interface through which information transfers in or out sequentially one bit at a time.

@sonofcy I do somewhat bit not fully.

@david_2018 Got it.

Would be nice if serial monitor would work with the Unix "curses" library.
https://heather.cs.ucdavis.edu/~matloff/UnixAndC/CLanguage/Curses.pdf

Bearing in mind the time it has taken for the Serial monitor to be moved to its own floating window and to fix the bug that prevents the full text in it to be selected I would not hold your breath

3 Likes

Good point, but I still wish. :neutral_face:

Everyone here makes great points. But in my case i wish I can only see the current value of things and not the past. I know it's great to see where the values have been. But in my cause it's more like to see if things are jamming up and where. It's not a big deal really. I was just wondering.

Thank you all @JCA34F @david_2018 @sonofcy @UKHeliBob For the help. As always the community is awesome.

The for loop I added at the bottom of your code will give the illusion the data is updating on the serial monitor in place. It actually just pushes the previous data off the screen.

I changed the baud rate to 115200 for it to perform smoother.
Untested

void setup() {
  Serial.begin(115200);
}
void loop() {
  int sensorValue = analogRead(A0);
  Serial.println(sensorValue);
Serial.println("");
   int sensorValue2 = analogRead(A1);
  Serial.println(sensorValue2);
  
  Serial.println("");
  
   int sensorValue3 = analogRead(A2);
  Serial.println(sensorValue3);
  
  Serial.println("");
  
   int sensorValue4 = analogRead(A3);
  Serial.println(sensorValue4);
  
  Serial.println("");
  
   int sensorValue5 = analogRead(A4);
  Serial.println(sensorValue5);
  
Serial.println("");

   int sensorValue6 = analogRead(A5);
  Serial.println(sensorValue6);

    delay(1000);

    for (int i = 1; i < 40; i++) {
      Serial.println();
    }
}

@2112 interesting it stays at the bottom like that. Thank you

In theory, one could use that method to emulate a 16x2 or 20x4 LCD in Serial Monitor. Also, if one reduces the height of SM appropriately, one can minimize the number of blank lines needed.
Interesting. Another rabbit hole to avoid this morning.

@camsysca That is true.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.