Go Down

Topic: LCD help (newbie) (Read 654 times) previous topic - next topic

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..

Doddy

#1
Mar 23, 2013, 09:08 pm Last Edit: Mar 23, 2013, 09:14 pm by Doddy Reason: 1
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: [Select]

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)

thanks! :) 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?

floresta

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

Don


Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy