LCD help (newbie)

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

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.

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! :slight_smile: 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 --> Cursor position after lcd.print() and lcd.scrollDisplayLeft() - #18 by floresta - Displays - Arduino Forum

Don

Thanks a lot!!!! :smiley: