LCD - Problems with characters

Hellow !

I have an issue with my Arduino's LCD.

I'm controlling a DC motor and i need to display motor's RPM and the PWM pulse lenght.
To print the PWM lenght, i use this code :

lcd.setCursor(0,0);
lcd.print(potValue);

The code works, but if i go up to 254 and than i come back to less then 100, i have on the display, for example, 400 instead 40, or 340 instead 34.

With the RPM i have the same problem. If i go up to 3000 and the i come back to less then 1000, for example 800, my LCD print 8000.

How can i resolve the problem ?

TNX !

You are not the first one to run into this problem!

Look here for at least two solutions --> Arduino Forum

Don

Thank you very much floresta !

It works very well.

For RPM i just wrote :

int RPM=rpm;

lcd.setCursor(10,2);
lcd.print(RPM);
if ( RPM < 1000) lcd.print(' ');

and for the PWM pulse i wrote :

lcd.setCursor(0,0);
lcd.print(potValue);
if ( potValue < 100 ) lcd.print(' ');

Thank you !