I want the bottom row of my LCD to display the counting function and include text:
lcd.setCursor(0, 1);
lcd.print("Launch in"millis()/1000);
But it comes out with an error, what part is wrong?
3 Answers 3
The last line in the code you provided won't compile.
The lcd.print()
function expects a char, byte, int, long or string (taken from the LiquidCrystal docs) and you're trying to combine a string and an int which the compiler isn't going to understand.
The easiest way to print both would be to have two lcd.print statements:
lcd.print("launch in ");
lcd.print(millis()/1000);
Most of this is taken from quickly googling displaying time on an lcd screen. Check out this forum post, it seems similar to what you want to do: click me!
lcd.setCursor(0, 1);
lcd.print("Launch in ");
lcd.print(millis()/1000);
-
2Can you add why the original code didn't work? Answers are best if they have some explanation, not just code.Anonymous Penguin– Anonymous Penguin2014年08月06日 16:58:37 +00:00Commented Aug 6, 2014 at 16:58
Change the last line to:
lcd.print("Launch in " + (millis() / 1000));
The +
concatenates the string Launch in
with the number that results from millis() / 1000
.