noob: update lcd characters

Hi
I am using sofwareSerial to send data to an LCD...
my problem is that if I print a value with 3 digits and the next value has only one digit, the last two digits of the previous value are still on the lcd...
to make myself clear...
if I print 168 it prints ok
if the next number is 7 it prints the 7 but the number on the LCD is 768 :frowning:

How can I resolve this issue?Can I set the format of the integer to have 3 digits all the time?

John

Can I set the format of the integer to have 3 digits all the time?

Depends on how you convert the integer to a string. If you use itoa, then, no. If you use sprintf, then, yes. If you let the LCD library handle the conversion, then you need to look at how it does it.

You could always write 3 spaces, then reset the cursor and write your number.

I did not know that I need to convert the interger to string...
I thought that you only had to define a format parameter...

thank u
I check the forum on how to convert the integer to string..

From one newb to another,

I wrote this routine that I call each time I want to output to the LCD. I have a 16x2 LCD and I'm sure actual programmers could point out where I use unnecessary commands or ways it could be done better. You can see the 2nd and 3rd statement clear the display line of what was on it before by a brute force writing of blanks.

void LCD_Static(int Col, int Row, String Text) {
Serial.begin(9600);
lcd.setCursor(0, Row);
lcd.print(" ");
lcd.setCursor(Col, Row);
lcd.noAutoscroll();
lcd.print(Text);
}

I call it LCD_Static because I was planning on writing another routine I would call to write to the LCD and it would then scroll that line. I found the Autoscroll() command scrolls both lines of the LCD rather than just one; not what I wanted.

Hope this helps you.

I'll give it a try...thank u!