 # Show value variable in Lcd problem

If I show the value of a init variable in lcd, for example lcd.setcursor(4,10); lcd.print (value);

The value shown at position 10, but the value is four digits, so the sample from left to right at positions 10, 11, 12, 13. But show begins to at position 10.

As the value goes down from four to three, two, or one digits, in the lcd the last value of digit is left written.

So if the value is 975 for example, goes when down to 50 the lcd sample 0950.

How can I fix this?

You need to write spaces over the number before you write the value. The LCD keeps displaying the same until something else comes over the top of it.

``````lcd.setcursor(4,10);
lcd.print("    ");
lcd.setcursor(4,10);
lcd.print (value);
``````

So do but value is flashing.

Then do it the other way round and print value followed by 3 spaces

``````lcd.setcursor(4,10);
lcd.print (value);
lcd.print("   ");
``````

This will be OK as long as you have nothing immediately after value. If you do, then you need to print just enough spaces to overwrite the extra digits by checking the length of value.

Another alternative is to only write value if it has changed. That will certainly stop it flashing.

The constantly changing value from 0 to 1000, I bow more for the option of measuring the length and write the necessary spaces.

I will study how make the routine.

Solved.

int i; i=sizeof(Watiostxt); if (i==3); lcd.WriteText(3,18," ",1); if (i==2); lcd.WriteText(3,17," ",1); if (i==1); lcd.WriteText(3,16," ",1); lcd.WriteText(3,15,Watiostxt,1);

Thanks.