overwriting/updating output to console

I want to print out output from a sensor to the arduino serial monitor continuously. So, I have this while loop

while(1){ Serial.print("Temperature: "); Serial.println(sensor); //sensor is the output value for the sensor }

Here's my question: How can I improve this so that it prints temperature only once and continuously updates "sensor". So instead of this:

temperature: 10 temperature: 12 temperature: 11

you would have temperature: 10 (12,11)// so it's just one line of output but 10 changing to 12 and then 11

Pls help!!! Thanks!

It depends on the terminal that you're using, but a common approach for many terminals is to support the carriage return as "go to beginning of THIS line" while a newline is "go to beginning of NEXT line."

while (1)
  Serial.print("Temperature: ");
  Serial.print(sensor);  //sensor is the output value for the sensor
  Serial.print("[glow]   [/glow]\r");

The extra spaces is to ensure the prior number is thoroughly scrubbed, otherwise you might see old digits remaining when new temperatures have fewer digits.

Halley: Sorry but that didn’t work. Am i doing something wrong?

The serial monitor built into the IDE is not a terminal program and is not meant to allow you to "format" the output.

You'll have to use some kind of real terminal application like Hyperterminal or ZTerm. To have true control over the output you'll have to send the appropriate character sequences for whichever terminal type you've selected to emulate.

You could buy a TellyMate shield and plug it into the TV - that way you get full terminal abilities (including overprinting values) on a big screen. Alternatively use Windows Hyperterminal or something like PuTTY (http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html).