Pages: [1]   Go Down
Author Topic: LCD help (newbie)  (Read 484 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm new to arduino and LCDs as well.. I wanna ask if I have to always use setCursor if I want to print messages on the same line.. For instance, I want to print "WATER LEVEL:80%", but the 80 part is a variable(named level) that depends on an input.. I can't remember what language allows you to print it like this: ("WATER LEVEL: " & level & "%"), but is it possible on arduino with the lcd.print command? or do I have to print them one by one, for example lcd.print("WATER LEVEL: ") then lcd.print(level) then lcd.print("%")? If it's the latter, do I have to set the cursor in between prints? where does the cursor go after printing? thanks in advance..
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't know much about the LCD driver that you're using, but you could always use the "sprintf" function to format a string variable with the value to be displayed embedded, then print the resulting file.

Code:
char buffer [17];  // 17 chars = "WATER LEVEL 100%" & null

sprintf(buffer, "WATER LEVEL %3d", level);
lcd.print(buffer);

...it does use ram, for the buffer, and more NVM for the library (I guess)
« Last Edit: March 23, 2013, 03:14:34 pm by Doddy » Logged

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

thanks! smiley but do you know where the cursor goes after lcd.print? does it, by default, go to the next box after the last character of the last line printed?
Logged

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

I seem to remember answering this question for you yesterday, here --> http://arduino.cc/forum/index.php/topic,146952.msg1169530.html#msg1169530

Don
Logged

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

Thanks a lot!!!! smiley-grin
Logged

Pages: [1]   Go Up
Jump to: