Go Down

Topic: LCD help (newbie) (Read 1 time) 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..


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);

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


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



Go Up