I have the HD44780 20 x 4 LCD that I got from Hacktronics (20 x 4 LCD White on Blue).
When I output a really long string of text using lcd.print(), the text wrap goes from the 1st line to the 3rd, then the 2nd, and finally to the 4th. If I manually set the line using lcd.setCursor(), they print in the correct order.
I have my Arduino Duemilanove wired to the LCD using the setup at Arduino Character LCD Tutorial.
The code I've attached below shows an example of what's happing. I initially print using setCursor() to position the text on specific lines. This displays:
Hello, World
hacktronics.com
Row 3
Row 4
It then delays for 15 seconds and then displays:
Why doesn't word wra
goes from line 1 to
p work correctly it
3 to 2 then 4
#include <LiquidCrystal.h>
// Connections:
// rs (LCD pin 4) to Arduino pin 12
// rw (LCD pin 5) to Arduino pin 11
// enable (LCD pin 6) to Arduino pin 10
// LCD pin 15 to Arduino pin 13
// LCD pins d4(11), d5(12), d6(13), d7(14) to Arduino pins 5, 4, 3, 2
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
int backLight = 13; // pin 13 will control the backlight
void setup()
{
pinMode(backLight, OUTPUT);
digitalWrite(backLight, HIGH); // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off.
lcd.begin(20,4);
lcd.clear(); // start with a blank screen
lcd.setCursor(0,0); // set cursor to column 0, row 0 (the first row)
lcd.print("Hello, World"); // change this text to whatever you like. keep it clean.
lcd.setCursor(0,1); // set cursor to column 0, row 1
lcd.print("hacktronics.com");
// if you have a 4 row LCD, uncomment out these lines to write to the bottom rows
lcd.setCursor(0,2); // set cursor to column 0, row 2
lcd.print("Row 3");
lcd.setCursor(0,3); // set cursor to column 0, row 3
lcd.print("Row 4");
lcd.setCursor(7,2);
delay(15000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Why doesn't word wrap work correctly it goes from line 1 to 3 to 2 then 4");
}
void loop()
{
}