20x4 LCD not working - black boxes only

I've looked at a few tutorials for setting up an LCD and I keep ending up with the same output. I've deconstructed it to work on a different project, then re-set up the wiring getting the same output. I've only installed the preloaded LCD library in the Arduino IDE. My guess is I need a different library.

I set up my circuit according to this, but I had tried other arrangements too. The backlight works and I'm able to adjust the contrast.

The code compiles and I'm able to upload the sketch onto the Arduino mega, but I don't get any change to the LCD. My Arduino is actually a knock off. The brand is Elegoo, but I've been able to connect and read several sensor without issue.

Here is the most recent code I am trying... Is the library the culprit or is there anything else I should be doing? Thanks in advance!

// include the library code:
#include <LiquidCrystal.h>

// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

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() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis() / 1000);
}

Have you grounded WR ?

A photo would be most illuminating(!).

The best way to do this unless your workshop is lit by multiple floodlamps, is to take it outside in full daylight but not direct sun and use a digital camera (that is, not to be confused with a telephone) at least a metre away from directly above (or very slightly offset to ensure all the connections are able to be distinguished) using the (actual) zoom to just include all parts of the assembly.

tasmod:
Have you grounded WR ?

That would be R/W (pin 5 on the LCD module).

Don

My setup is currently a bit of a mess. I might have to deconstruct it and rebuild it for the purpose of clarity...

Disregard these next couple posts. Rather than wait and post a couple more pictures, I'm building a photogenic one...

More pictures will be coming every 5 minutes...

Another

Turn down the contrast to the point where the black pixels just disappear.

When you have complete rows of black boxes as in #4 it means the controller has initialised fine. Your contrast is wrong.
When you see one row of boxes on a 16x2 or two rows on a 20x4, the initialisation has failed. Generally this means your wiring is wrong.

Ok, these pictures are the good ones now. Re-wired, different wire, same result. I was getting the same result before soldering too. I initially was laying the LCD against the breadboard, inserting wires, and after a few were inserted it would hold in place. When the contrast is changed just to the point where the black boxes disappear, then I get nothing.

Here's a picture of the pin connections.

I found this link below in the question/answer section of where I bought this on Amazon. My LCD would be 80 characters, so I'm looking at the first chart. It's weird that pins 15 and 16 aren't listed because that's where it's drawing it's power. I've seen other places mention to start with 3 pins, the 5v, ground, and potentiometer. For me, that's 15, 16, and 3. I also have pins 1 and 2 hooked up to ground and 5v, but the backlight still lights when I remove those.

Is this chart saying I should have pins 7-10 connected to a digital pin?

I should have said pins 8-11. But yes, apparently I do need to hook those up. I updated my code below and now it works.

// include the library code:
#include <LiquidCrystal.h>

// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d0 = 9, d1 = 8, d2 = 7, d3 = 6, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d0, d1, d2, d3, d4, d5, d6, d7);

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() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis() / 1000);
}

OK, clearly the problem has been your wiring and in particular pin 5, the read-write pin. No, it was not necessary to connect pins 7 to 10.

It seems that you originally and possibly still now had pin 5 connected to some random pin on the Arduino that you did not include in the descriptor. If you do not include it in the descriptor, it must be connected to ground.

I also get the impression that you have an odd LCD where pins 15 and 16 come before pin 1 - is that the case? Or it seems - one on each end?

An interesting tip, not involved with your present problem, but a blunder that has been propagated through a long history of these displays. Do not connect the potentiometer to Vcc - leave that end disconnected or connect it to the wiper. This will make contrast setting easier and has another incidental advantage.

For convenience, your pictures. You have - not surprisingly - ignored my advice regarding adequate lighting but they are sort of usable:

a0340c67325d9079bcedba534c7ddf17b5f46fb5.jpg

22799cf5d32a0a425e9b9d91aa7b00344c829ae5.jpg

724ca133361f0780c50d1db0a026ae7cfeea1bcd.jpg

028d0a0eb6b912e4f5924a8db40e644968dcef63.jpg

c49b6167ef9190d532b758ae09e31e3e8df76b82.jpg

You're right, I did not purchase photo studio lighting for your needs. Nor did I take my computer and all of my small parts outside to the sidewalk of the city where I would not have an outlet. As for pin 5 that was and still is connected to ground. I stated that everything was wired according to the diagram in this link.

I'm curious how you think pin 5 was the issue when I haven't changed how that was set up. The only changes that I made were to pins 8-11 and the code related to pins 8-11. Now it works perfectly.

My pins move 1-16 from left to right if you're facing the LCD side of the board. The back of the board has a 1 printed on one side of the pins and a 16 on the other so there is no room for confusion there.

EDIT I'm all over the map. I did mean pins 7-10... The reason for my confusion is I forgot to mention a different error I had found. I had pin 7 of the LCD plugged into pin 5 of the Arduino, instead of pin 11 of the LCD. Fixing that led to the display working, but the characters were wrong. It was just random characters and arrows. Connecting pins 7-10 corrected the character issue.

Well, unfortunately without an adequately illuminated and therefore, focussed photograph, it was simply not possible to check your connections.

Getting "random characters and arrows" suggests that the connection on pin 14 of the LCD was faulty. Many such complaints we see here relate to faulty "Dupont" jumpers.

If it now works with pins 7 to 10 connected, it most certainly should work with them disconnected and the descriptor abbreviated to match.

Dammit. You're right. While not 100% right, you're right. Messing with pin 14 gives Russian looking characters. When I thought I pulled pins 7-10 and altered the code, I forgot to factor that initial mistake and how that affected my breadboard. I pulled pins 8-11... So it was not having pin 11 on the LCD that was giving me the wrong characters.

You are not right about the photographs, though. While slightly out of focus you are able to clearly read the pin numbers and see the colors of the wires. The issue was the initial wiring being sloppy, and that was the setup that I took more pictures of. Your request that people either purchase flood lamps or take everything outside, and purchase a digital camera is unreasonable.

While I fixed my display on my own, thank you very much for pushing me to find the true issue and not accepting my faulty explanation.