20x4 lcd problem

Hello,

I have looked a bit and have not been able to find any clear answers. I have a generic 20x4 lcd (ebay) connected to my arduino mega 2560.

When I run the example sketch "display", the lcd works fine. When I modify the sketch to move (lcd.setCursor():wink: the writing to the 2nd or 4th row, it does not print correctly (you can faintly see "hello,world" but it is scrambled). When I modify the sketch to print the writing on the 3rd row it works fine also.

Look closely at the picture.. There is a horizontal line in the 2nd and 4th rows. Perhaps this is just a defective lcd?

Here's the code:

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(41, 39, 37, 35, 33, 31);

void setup() {
  // set up the LCD's number of columns and rows: 
  lcd.begin(20, 4);
  // Print a message to the LCD.
  lcd.setCursor(3,1);
  lcd.print("hello, world!");
}

void loop() {
  // Turn off the display:
  lcd.noDisplay();
  delay(500);
   // Turn on the display:
  lcd.display();
  delay(500);
}

Thanks,
Camoren

Please edit your post. Highlight the stuff that is code and then press the 'code' button which looks like an octothorpe ( # ).

If you are having trouble getting an LCD to work properly then the last thing you want is to have things changing on you as you troubleshoot. Basically this means that loop() should be empty (nothing between the { } brackets).

Try these two sketches and see what happens (you can add two more display lines to the first one).

#include <LiquidCrystal.h>

//LiquidCrystal lcd(RS, E, D4, D5, D6, D7);
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);      // put your pin numbers here

void setup()
  {
  lcd.begin(16, 2);                          // put your LCD parameters here
  lcd.print("hello, world!");
  lcd.setCursor(0,1);
  lcd.print("it works!");
  }

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

Don,

Thanks for the reply. I edited my first post and also ran the first code that you gave me. The display prints the characters to the first row, then to the 3rd row (everything looks fine to this point) then it prints the characters to the 2nd row, then to the 4th. When it prints to the second and fourth rows, the characters are all screwed up and it then jumbles the characters on the 1st and 3rd rows.

I hope that I am doing a alright job of explaining this.

It appears to me that something is wrong with the communication between the main controller and the last two of the four auxiliary controllers on your pc board. In that case there's not much you can do except replace the display.

Don

I'd check the connections again, I had a similar issue and then I realized one pin was not wired correctly.

I'd check the connections again, I had a similar issue and then I realized one pin was not wired correctly.

I doubt that your issue was similar. Improper wiring generally results in no characters or characters that are always jumbled but not characters that change from normal to jumbled when other characters are displayed.

Don

I had 2 wires wrong and the lcd displayed swapped lines, on GLCD 128x64, different driver but parallel also.