2 Line LCD, lcd.print with multiple vars

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
sirmichael
 
Posts: 21
Joined: Wed Mar 19, 2014 10:10 pm

2 Line LCD, lcd.print with multiple vars

Post by sirmichael »

I have the Example that comes with the 2 line LCD working (installed the CPP and .H file OK).

The lcd.print("Hello World"); prints OK, but I was wondering if there was a way to print multiple variables without having to pre-construct the string.

I want to use: lcd.print( Hours + ":" + Minutes);

I can't find any examples other than just the simple ones in the example code.
I'd perfer not to use something like: mystring =String(Hours, INT) + ":" + String(Minutes, INT);
lcd.print(mystring)

Can anyone tell me if this works?
Where do I find more information on the calls that are available in the library? (Help file?)
I am somewhat of a newbie in the Arduino, but I do have some programming experience.

I can't try it right now because the LCD unit that I ordered went bad and I'm waiting for a new kit to arrive, but I'm trying to write the code.

Mike

User avatar
Franklin97355
 
Posts: 23911
Joined: Mon Apr 21, 2008 2:33 pm

Re: 2 Line LCD, lcd.print with multiple vars

Post by Franklin97355 »

This works for me:

Code: Select all

 lcd.clear();
    lcd.setCursor(0,0);
    lcd.print(F("Speed: "));
    lcd.print (avgmph);   
    lcd.print(F(", Dir: "));
    convDir(windDir);
    lcd.print(compass);
    lcd.setCursor(0,1);
    lcd.print(F("Temp: "));
    lcd.print(temp_c);
    lcd.print(F("C/"));
    lcd.print(temp_f);
    lcd.print(F("F"));
    lcd.setCursor(0,2);
    lcd.print(F("Humidity: "));
    lcd.print(humidity);
    lcd.print(F("%"));

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”