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.
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).
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.