Go Down

Topic: Prevent new entries with Serial.print (Read 963 times) previous topic - next topic

budabob07

Is there a way to make it so a number printed with serial.print doesnt make a new value in the serial monitor, but instead just changes?  So instead of looking like this

5
5
5
4
4
4

It would just look like this:
4
But the number would change whenever the value updated
I've done this on a BASIC micro with "Debug.HOME", but can't work out how to do it with an arduino.  Also, i couldn't find anything in the documentation for Serial.print.  Is this possible?

Coding Badly

Code: [Select]
int PreviousNumber;

void loop( void )
{
 int ThisNumber;

 ThisNumber = 13 /* your code goes here to set ThisNumber to the current value */

 if ( ThisNumber != PreviousNumber )
 {
   Serial.println( ThisNumber );
   PreviousNumber = ThisNumber;
 }
}

budabob07

Thanks, but that still doesn't replace the old one with the new one.  It will still create a new line with a number whenever the value changes.  I'm wondering if it is possible to have only one entry on the serial monitor, and have that entry change whenever the value is updated, without ever adding more lines to the serial monitor.

wildbill

Consensus from some old threads (search serial monitor clear) is that you can't do it in the IDE serial monitor. If you use some other serial terminal program though, you can send control characters to it that will clear it or at least just do a carriage return and overwrite.

budabob07


Go Up