20x4 LCD QC2004A on Mega2560

That is the item I’ve purchased. I am very new to arduino and fairly new to programming.

I am using the built-in examples from the arduino IDE. I change the lcd.begin from 16,2 to 20,4. I also add the 4 extra pins. Here is the sample I am working with:

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11,9, 8, 7, 6, 5, 4, 3, 2);

void setup() {
// set up the LCD’s number of columns and rows:
lcd.begin(20, 4);
// Print a message to the LCD.
lcd.print(“1234567890abcdefghijklmnopqrstuvwxyz”);
}

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

All I get is gibberish though across 2 lines. I use a switch to disconnect the power/ground from the display. Whenever I re-load the code I get a new set of gibberish across the 2 lines.

Can anyone point me in the right direction?

I’ve tried searching but everyone has an I2C module (I think that is what it is called) connected on the back. I don’t have anything special with it. Just the 16 header pins connected directly to my bb and soldered onto the display board.

You do not need the '4 extra pins' just because you have a display with four rows of characters instead of two.

By adding the extra numbers to the constructor you are telling the library that you are using 8 data wires instead of four. If you tell it that you are using 8 data wires then you have to actually use 8 data wires.

You are better off just using 4 data lines, there's really no advantage in using 8.

(1) Replace the LiquidCrystal lcd(12, 11,9, 8, 7, 6, 5, 4, 3, 2); statement with the original one and make sure your wires are connected accordingly.

(2) Remove all of the stuff between the brackets in loop().

(3) Don't be surprised when your line of characters overflows onto the third row instead of the second.

Don

Yes, I understand the concept of using the 8 bits opposed to the 4 bits. I have the wiring correct. 2-9 go directly to db7-db0. I followed the instructions from the arduino website for the 4 bit and just added the other 4.

If I use just the 4, with the regular example I still have trouble.

I'm just going to have to test the LCD pins to see if I messed up during the soldering.

I just can't seem to get a consistent output and it's driving me bonkers.

How about giving us some more definitive information so we can get this solved quickly?

All I get is gibberish though across 2 lines.

Which two lines? It would help if we knew what the gibberish looks like. It would also help if the string of characters that you send has some repeating characters in it.

I just can't seem to get a consistent output ...

Does this mean that the gibberish changes each time you run the code?

Don

It is across the 1st and 3rd line as mentioned above. I just have to write something to fix the lines skipping (1st, 3rd, 2nd, 4th) but when I connected to 8-bit it wouldn't output the correct information.

I guess I'll just stick to the 4-bit like mentioned as well. Seems to be working fine with just the 4 wires. Thanks for the help.

Well it seems that the issue wasn't that simple. I believe there is a problem with the actual LCD. I've testing the soldering and there doesn't seem to be an issue with and shorting of pins.

While it did work for a short while using the 4 wires, I still have yet to be able to continually receive a constant working display. All the lights come on. I can get the contrast to work fine but the information doesn't display (i.e. hello world!).

I've tried moving it to another area on the bb, check, recheck and re-rechecked the connections and everything was fine.

Is there a specific way of working the LCD? I am going to return this one for a new one (different brand/manufacturer). I basically plug everything into the bb and arduino and then power it up. Sometimes I'll get the gibberish again, most times I just get a blank screen with boxes that I can manipulate using the contrast.

At the moment I cannot get anything to pop up on the screen, other then lines 1 and 3 showing the completely filled character space (the boxes when I raise the contrast to full), while lines 2 and 4 do not respond. Again, just simple code but nothing.

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

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

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

Hi,

I recently had the same problem. My solution: Check the whole circuit several times!
Every connection has to be correct when starting the upload. In my case a soldering wasn't correct.

I hope this will help you.