Variables not showing on LCD screen

I have a 2 line 16 character display and it is not displaying any variables

I post the same message to twitter so I wanted to keep the same format, I just added some spaces to push some of the info onto the second line, however when running the following section of code

sprintf(msg, "Daylight: %d:%02d %dC", hour(),minute(), (tweettemp) );

lcd.clear();
lcd.print(msg);

I get

Daylight:xxxxxxx
xxxxxxxxxxxxxxxx

where x is a blank space, however all the info gets tweeted correctly

Daylight: 18:25 26C

I have attached the full code, can someone please point out my cockup:-)

Thanks

Steve

postable.ino (22 KB)

Your LCD screen does not display your 'msg' the way that you expect.

Although it can display a total of 32 characters the messages do not wrap from the first line to the second the way you would think.

If you send 40 sequential characters to a 16x2 display the first 16 will be displayed on the top line and the next 24 will not be displayed at all.

For the reasons behind this unusual behavior follow the LCD Addressing link at http://web.alfredstate.edu/weimandn.

You will have to break your messages into two 16 character chunks and send the first to the first line and the second to the second line.

Don

perfect thx, I had assumed it wrapped to the next line and the error was due to the info being variable :slight_smile: