How to display stuff on two lines of a 16x2 LCD display

Hello,

I am using an LCD display that i purchased from amazon : http://www.amazon.com/microtivity-IM161-Module-White-Backlight/dp/B0059H60SK/ref=sr_1_3?ie=UTF8&qid=1341586402&sr=8-3&keywords=arduino+lcd+display
I also was able to connect it as shown here and able to get teh "hello world" display going: http://arduino.cc/en/Tutorial/LiquidCrystal
But this only uses the top row of my display, I want to write stuff on the bottom row too, can someone tell me how to do that??
I am using ATMEGA 328p with arduino.

Look at the setCursor() member function.

But this only uses the top row of my display

What happens when the string you are writing to the LCD exceeds 16 characters in length?

I did a project with a 4X40 display. I set up 4 arrays to act as line buffers so I could also do minor edits and then rewrite the whole line.
I was accepting data from a keyboard so I would copy the lower lines to the upper lines in the array, fill the lower line array with spaces and then write the lines to the display.

All I used was the SetCursor() function prior to writing each line to the display.

The only time I had any problem was if I wrote past the end of the bottom line the cursor would wind up at the top left, which was not a desired action.

Remember - the first line is line 0, and the second line is line 1

PaulS:

But this only uses the top row of my display

What happens when the string you are writing to the LCD exceeds 16 characters in length?

only 16 are displayed, the rest are omitted!

Arrch:
Look at the setCursor() member function.

Thanks for the tip, did it and it worked.
For those who might need it in future, here is the code

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
// set up the LCD’s number of columns and rows:
lcd.begin(16, 2);
lcd.setCursor(0,0);
// Print a message to the LCD.
lcd.print(“First line”);
lcd.setCursor(0,1);
lcd.print(“Second line”);
}

void loop() {
// Turn off the blinking cursor:
lcd.noBlink();
delay(3000);
// Turn on the blinking cursor:
lcd.blink();
delay(3000);
}

1 Like