LCD 4x20 Row 3 and 4, Set Cursor negative works.

Hi
I got a weird problem with a 4x20 LCD. The first 2 rows working but Row 3 and 4 are moved to the right 4 positions.

I have tried:
lcd.setCursor(-4,2);
lcd.setCursor(-4,3);

And that works.

Whats wrong?

Best regards
Ole

#include <LiquidCrystal.h>

LiquidCrystal lcd(11, 10, 9, 8, 7, 6);

void setup() {
  lcd.begin(20, 4);
}
void loop() {
  lcd.setCursor(0,0);
  lcd.print("Row1");
  lcd.setCursor(0,1);
  lcd.print("Row2");
  lcd.setCursor(0,2);
  lcd.print("Row3");
  lcd.setCursor(0,3);
  lcd.print("Row4");
}

IMG_2226.jpg

IMG_2227.jpg

I hate to be the one to tell you this but you have a 4x16 display, not 4x20. :frowning:

Very good observation John.

Ole,

Take a good look at the memory maps for the displays, especially the 20x4 and the 16x4 in this document.

http://web.alfredstate.edu/weimandn/lcd/lcd_addressing/lcd_addressing_index.html

The setCursor is placing the cursor at an address, and since you have declared it as a 20x4 is is using its memory locations for the start of the rows. If you look at the 16x4 memory map you can see that memory location start of row 3 and 4 is four less than the memory locations at the start of the rows in 20x4.

Try lcd.begin(16,4)