mapped value showing wrong on lcd

Hi.

I have problem with a mapped value from a pot showing wrong on the lcd. In the serial.monitor it turns up right. The mapped value is from o to 1000.

When booting arduino and turning the pot up to full it show the right value but when i turn it down again from 1000 the last digit "0" wont disappear.For ex. mapped value 790 shows 7900 on the lcd.
How do i fix this?

Print spaces where digits used to be.

LCD.print(potVal);
LCD.print("   ";

This will write several spaces after the potentiometer value, "erasing" any "leftover digits".

Hi,
Welcome to the forum

Yes, you are doing the equivalent of over printing your digits each time to display the number.

If you display a 4digit number , say 1234, then display a 3digit number say 999, it will display 9994,
The 4 is left over from the previous dislplay.

A solution is to display 4 spaces just before you display your number again.

If you need more help please post you code.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Tom... :slight_smile:

Added 4 spaces before lcd.print and I got it working, thank you for the help.

Only now is the value on the lcd screen flikering rapidly. This probebly because its updateing all the time.

This probebly because its updateing all the time.

Yes. Keep track of the value you last printed, and don’t print the current value unless it is different from the last value.

Perfect.

Thank you !