A very persistant zero on my LCD display

I've just started playing with LCD displays, the problem I'm having is probably a simple one but I just don't see it.
I'm printing an analog value, when the value drops to single digits the zero from the ten doesn't clear from the display. Eg. A value of 7 shows as 70.
I've tried "delay(xxx);
lcd. clear();"
This creates an annoying flicker.
And mapping the value " 00-100 " with no luck.

Please help, thanks

Once you write a character to the LCD it stays there until it is overwritten.
To 'erase' a character you have to overwrite it with a 'space'.

The best way to deal with displaying changing data is to:
(1) position the cursor
(2) display enough spaces to cover up all of the earlier data
(3) reposition the cursor
(4) display your new data

lcd.clear is not a good choice because (1) it takes a long time and (2) it may cause flicker (as you have seen).

Don

Ill give that a try, thanks.

Here is a tutorial of using the function sprintf to do what Don mentioned in step 2:

I do this for all my LCD outputs.

Try this:

lcd.setCursor(0,0);

lcd.print("Value  : ");                                                                                         
if (value < 10) lcd.print("   ");                  
else if (value < 100) lcd.print("  ");
else if (value < 1000) lcd.print(' ');

lcd.print(value, DEC);

buracek:
Try this:

lcd.setCursor(0,0);

lcd.print("Value  : ");                                                                                        
if (value < 10) lcd.print("   ");                  
else if (value < 100) lcd.print("  ");
else if (value < 1000) lcd.print(' ');

lcd.print(value, DEC);

Or slightly shorter/cleaner:

lcd.print("Value  : ");                                                                                         
if (value < 1000) lcd.print(" ");
if (value < 100) lcd.print(" ");
if (value < 10) lcd.print(" ");                  

lcd.print(value, DEC);

You will notice that your compiled program is shorter with this method. The compiler treats " ", " ", and " " as separate strings, so you will save 2 bytes (by my testing) this way.

lcd.print("Value : "); //one space after ":"
if (value < 1000) lcd.print(" ");
if (value < 100) lcd.print(" ");
if (value < 10) lcd.print(" ");

lcd.print(value, DEC);

Sketch uses 1786 bytes .......
Global variables use 51 bytes of dynamic memory...

================================

lcd.print("Value : "); //two spaces after ":"
//if (value < 1000) lcd.print(" ");
if (value < 100) lcd.print(" ");
if (value < 10) lcd.print(" ");

lcd.print(value, DEC);

Sketch uses 1780 bytes ==> -6 bytes
Global variables use 53 bytes of dynamic memory...==> +2 bytes

=====================

lcd.print("Value : "); //two spaces after ":"
//if (value < 1000) lcd.print(" ");
if (value < 100) lcd.print(" ");
else if (value < 10) lcd.print(" ");

lcd.print(value, DEC);

Sketch uses 1772 bytes ==> -14 bytes
Global variables use 53 bytes of dynamic memory...==> +2 bytes

ansvill2:
lcd.print("Value : "); //one space after ":"
if (value < 1000) lcd.print(" ");
if (value < 100) lcd.print(" ");
if (value < 10) lcd.print(" ");

lcd.print(value, DEC);

Sketch uses 1786 bytes .......
Global variables use 51 bytes of dynamic memory...

================================

lcd.print("Value : "); //two spaces after ":"
//if (value < 1000) lcd.print(" ");
if (value < 100) lcd.print(" ");
if (value < 10) lcd.print(" ");

lcd.print(value, DEC);

Sketch uses 1780 bytes ==> -6 bytes
Global variables use 53 bytes of dynamic memory...==> +2 bytes

=====================

lcd.print("Value : "); //two spaces after ":"
//if (value < 1000) lcd.print(" ");
if (value < 100) lcd.print(" ");
else if (value < 10) lcd.print(" ");

lcd.print(value, DEC);

Sketch uses 1772 bytes ==> -14 bytes
Global variables use 53 bytes of dynamic memory...==> +2 bytes

Moderator: Why do you revive an old thread from 5 yrs ago?