******** P R O B L E M S O L V E D ******* T H A N K S F O R Y O U R H E L P ************
It just so happens that the very first 4x20 LCD I bought in my life was bad. Odds?
The first 4 characters of line 4 overlays the last 4 characters of line 2 on my 4x20 LCD display with I2C adapter.
Arduino Uno R3 2012. Using fm's New LiquidCrystal library.
Naaah. I thought about the 16 chars deal, but it prints all 20 characters on each of the 4 lines.
It might be a hardware problem, I just don't know. I'm sure that if it were fm's LiquidCrystal library, someone would have run across this and fixed it before now. 4x20's are not uncommon.
I'm hoping to find a RSG (army speak for real smart guy) that will know the answer.
A 16x4 would definitely give you addressing problems with any library derived from the regular LiquidCrystal library but I think this is an unrelated problem.
To find out what is going on you should start by having the code run once and then stop. This means that your 'test' code should be in setup() and loop() should be blank (nothing between the brackets). Try that and let us know what happens.
Now you have to put a pause between each line to see when the problem occurs. You may even want to rewrite things to put a pause between each character.
The 2nd line prints correctly, but the last 4 characters of line 2 are duplicated on the 1st 4 characters of line 4.
The 3rd line prints correctly.
The 4th line prints correctly, but the first 4 characters of line 4 replace the last 4 characters of line 2.
They are obviously sharing the same memory space for those 4 characters.
I changed the sketch and put the code back in the Loop section with the pause between lines, but not clearing the screen between loops.
When line 2 is written, it changes back to the original content, but goofs up line 4, proving that they share memory space.
You can check out your hardware by using a variation of the following program which does not involve any addressing.
Here's what I typically recommend for a traditional parallel connection, you will need some minor modifications for your I2C setup.
#include <LiquidCrystal.h>
//LiquidCrystal lcd(rs,en,d4,d5,d6,d7);
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // put your pin numbers here
void setup()
{
lcd.begin(20, 4); // put your LCD parameters here
for (char i=47; i<127; i++) // send 80 consecutive displayable characters to the LCD
{
lcd.print(i);
delay(100); // this delay allows you to observe the addressing sequence
}
}
void loop()
{
}