Pages: [1]   Go Down
Author Topic: how to refresh lcd properly  (Read 2222 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 2
Posts: 226
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
i got a 20x4 lcd i2c and the following problem:

i have a sensor value first in the lcd and a counter next to that.

after some counts i got something like this in the display:

0.00__3

once the sensor value reaches 10 it becomes this:

10.00__3
but once the sensors value flips back to 0 it looks like this:
0.00__33
the lcd doesnt erase the 3/refresh the space _ once it goes back.

Could you tell me how to do that?

and can i make it somehow look like always _0.00 instead of 0.00 and moving all chars one space to the right after it reaches 10?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I guess you are trying to make a Data Logger. I had a similar problem. Here is what i did.

Fix the position of the value and the counter on the LCD before you print the data to the LCD. In  your case it will be
lcd.setCursor(col,rows);

lcd.clear();
lcd.setCursor(0,0);
lcd.print(val);
lcd.setCursor(5,0);
lcd.print(counter);

Quote
and can i make it somehow look like always _0.00 instead of 0.00 and moving all chars one space to the right after it reaches 10?

for this i added a trailing zero in case the value is less then 10. Use if-else statement

lcd.print("0"); \\ if value less then 10
lcd.print("");    \\ if value is more then 10

I am a beginner myself so i am sure this is a really crude method and lot of people will suggest more efficient coding but well , we all are learning ..aint we...
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 36
Posts: 4326
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
and lot of people will suggest more efficient coding
They already have ... many times.  Finding those posts is another matter.

Try this one: http://arduino.cc/forum/index.php?topic=94633.0


Don
« Last Edit: July 16, 2012, 10:02:17 am by floresta » Logged

Offline Offline
Full Member
***
Karma: 2
Posts: 226
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thx a lot,
this is great:
http://liudr.wordpress.com/2012/01/16/sprintf/

well actually im always searching first, but sometimes its not that easy for me to find the right thing, when you get like 400 search results.
Logged

Pages: [1]   Go Up
Jump to: