4x20 LCD I2C Adapter - 1st 4 char of line4 repeated over last 4 char of line2

******** 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.

Simple test program:

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

void setup()
{
  lcd.begin(20,4);               // initialize the lcd 
}

void loop()
{
   lcd.home();
   lcd.clear();
   lcd.print("Line2GoofedUpExample");
   lcd.setCursor ( 0,1);
   lcd.print("ThisIsTheSecondLine2");
   lcd.setCursor (0,2);
   lcd.print("ThisIsTheThirdLine33");
   lcd.setCursor(0,3);
   lcd.print("LastLineFirst4Repeat");   
   
   delay (2000);
}

This displays:

Line2GoofedUpExample
ThisIsTheSecondLLast
ThisTheThirdLine33
LastLineFirst4Repeat

No matter what I print in the 4th line, the 1st 4 characters overlay the contents of the last 4 characters of the 2nd line.

I tried this with 3 different I2C adapters from 2 different sources. I only have the one 4x20 LCD.

Anyone heard of this before?
Got any ideas for something I can try?

John

20-4=16. Is there any chance it is really a 16x4 ? Apparently they do exist:
http://www.amazon.com/JAMECO-VALUEPRO-16X4-PARALLEL-DISPLAY/dp/B00B88C0VK

Admittedly that is just a shot in the dark...

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.

John

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.

Don

Put all the code in the setup section. Nothing in the Loop Section. Arduino doing nothing very fast. :slight_smile:

Same results...........................Rats.....!!!!!

John

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.

Don

 void loop()
{
   lcd.home();
   lcd.clear();
   lcd.print("Line2GoofedUpExample");
   lcd.setCursor ( 0,1);
   lcd.print("ThisIsTheSecondLine2");
   lcd.setCursor (0,2);
   lcd.print("ThisIsTheThirdLine33");
   lcd.setCursor(0,3);
   lcd.print("LastLineFirst4Repeat");   
   
   delay (2000);
}

Do you see a "lcd.setCursor(0,4);" statement ?

Very wierd!

All characters are blanked out.

The first line prints correctly.

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.

Now all we need to know is hardware or software?

Hints?????????????

John

Very wierd!

All characters are blanked out.

The first line prints correctly.
etc

To which post are you responding?

Don

Do you see a "lcd.setCursor(0,4);" statement ?

No. Do you?

Don

I was answering Don's suggestion for a test with pause, but you posted between.

Now I'm trying to figure out what I did wrong, missing the 0,4

John

It's a 4 line display. Shouldn't there be one ?

Now I'm trying to figure out what I did wrong, missing the 0,4

Stop figuring. If you found one it would be wrong.

Don

It's a 4 line display. Shouldn't there be one ?

No. You start your counting with 1 but most programmers start with 0.

Don

Then it's missing the lcd.setCursor(0,0);"

You really need to look into the Instruction Set in the HD44780U datasheet. The 'Clear display' instruction would be a good place to start.

Don

Edit: In case anyone is wondering there is a post that has been deleted.

Fixed up test code. I didn't have a setCursor(0,0) because I was using home() and clear(). There is no (0,4), it's 0 thru 3.

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x20, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

void setup()
{
  lcd.begin(20,4);               // initialize the lcd 
   lcd.home();
   lcd.clear();
 }

void loop()
{
   lcd.setCursor ( 0,0);
   lcd.print("Line2GoofedUpExample");
   delay (5000);
   lcd.setCursor ( 0,1);
   lcd.print("ThisIsTheSecondLine2");
   delay (5000);
   lcd.setCursor (0,2);
   lcd.print("ThisIsTheThirdLine33");
   delay (5000);
   lcd.setCursor(0,3);
   lcd.print("LastLineFirst4Repeat");   
   delay (5000);
 }

The test result is the same. The last 4 of line2 shares memory with the first 4 of line4.

John

You start your counting with 1 but most programmers start with 0.

I guess that means I'm not a programmer yet...

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()
  {  
  }

Don

I didn't have a setCursor(0,0) because I was using home() and clear(). There is no (0,4), it's 0 thru 3

Correct!

John, do all of us a favor and get your display functioning properly with all of the code in setup before getting involved with loop.

Don

I guess that means I'm not a programmer yet...

I'm not either and I've been around longer than either of you (if the '1945' means what I think it does).

Don