LCD black boxes problem!

Hi Guys!
This is my first post here. I am tying to hook up a 16x2 LCD to an arduino uno. I am greeted with the most common problem(as I have heard). When I first uploaded code to the LCD it worked fine but now if I upload the code again, it shows both rows with black boxes! I googled it and it came up that i needed to disconnect the LCD but i couldn't figure out which pins to disconnect and if i (somehow) managed to ruin its setting, please guide me.
I am using the Liquid Crystal example code and there is nothing fancy about my setup. All the wiring is also correct.
HELP!
Regards
android2399.

Do you use a potentiometer to adjust the contrast ?

Here is my generic step by step approach that should work:

(1) If the module has a backlight then get it working properly. This involves only pins 15 and 16 on most LCD modules. Make sure to use a current limiting resistor if there is none on the LCD module.

(2) Get the power and contrast working properly. This involves only pins 1, 2, and 3 on most LCD modules. You should be able to just barely see blocks on one row of a two row display and on two rows of a four row display.

NOTE: The Arduino has not been used yet, except as a possible source for the power needed for the first two steps. Do not try to go any further until this is working. If you don't see the blocks then no amount of program code will help.

(3) Connect the LCD R/W pin (pin 5) to GND.

(4) Connect the six control and data wires between your LCD module and your Arduino.

(5) Upload your sketch and it should work.

Troubleshooting:

If you have a 16x1 display and there are blocks only on the left half of the row in step 2 then use

lcd.begin(8, 2);

in your sketch.

If you still don't get a display then make sure that your wiring matches the numbers in the descriptor (or vice versa).

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

If you get a display but it is garbled or has some other problems then try again with a 'static' sketch, one that displays a simple message on the top row of the display and then stops. All of your code should be in setup() and loop() should be empty between the brackets.

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

If you are still having problems then we need to see a photograph of your setup that clearly and unambiguously shows all of the connections between your Arduino and your LCD module. We also need a copy/paste version of the code that you are actually using, not a link to the code that you think you are using.

Don

I have tried all of the above but still no good. I have rechecked everything. Here is the code:

#include <LiquidCrystal.h>

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

void setup() {
  lcd.begin(16, 2);
  lcd.print("hello, world!");
}

void loop() {

}

And here are the pictures. Please take a look at them.

I have tried all of the above but still no good.

Show us what the set-up and the display look like after step (2).

Don

Well in this picture, the display module in only connected to power(by the Arduino) and contrast by the potentiometer. Only the top row gets ENLIGHTENED :wink:

That is what the LCD display should look like after step 2 although your backlight looks quite bright.

Now go ahead with steps 3, 4, and 5.

Don

I did steps 3,4,5 very carefully but still it shows the same top row lit, nothing has changed. Maybe I need to disconnect the display while uploading the code. I read this elsewhere on the forum, please guide me about that too. Thank you very much for your support! :smiley:

Okay. The most weirdest thing happened. After getting tired of trying to fix the problem I decided(to be an idiot and) to short the power lines(just for a tiny moment... :wink: ) and well what do you know, the next thing I see in front of me is a perfectly working LCD with "hello, world" displaying on it. I uploaded many other codes and they all worked. Now how on earth did that happen? Any suggestions? Or should I assume that the next time there is a power failure in the whole city, I should short out the mains! :smiley:

Maybe I need to disconnect the display while uploading the code. I read this elsewhere on the forum, please guide me about that too.

This would be a suggestion only if you are using pins 0 and 1.

I have no clue about your 'solution'.

Don

Disconnect the wire from pin 5 (RW) of the LCD - which you presently have connected to pin 11 of the Arduino - and connect it to ground instead.

{Technical comment - wrong descriptor for that configuration!}

Paul__B:
Disconnect the wire from pin 5 (RW) of the LCD - which you presently have connected to pin 11 of the Arduino - and connect it to ground instead.

{Technical comment - wrong descriptor for that configuration!}

We are way beyond those problems if he has followed my outline.

Don

arduino2399:
Okay. The most weirdest thing happened. After getting tired of trying to fix the problem I decided(to be an idiot and) to short the power lines(just for a tiny moment... :wink: ) and well what do you know, the next thing I see in front of me is a perfectly working LCD with "hello, world" displaying on it. I uploaded many other codes and they all worked. Now how on earth did that happen? Any suggestions? Or should I assume that the next time there is a power failure in the whole city, I should short out the mains! :smiley:

But how did this happen??

arduino2399:
But how did this happen?

Do please answer my question first - did doing what I recommended, actually and reliably fix the intermittent problem caused by using wiring that did not match the descriptor used?

Well I never had the R/W pin of the LCD connected to the Arduino, it was always connected to ground. So that did not fix the problem.

OK, trying to trace your wiring on those fuzzy photos, it definitely looked like R/~W was connected to pin 11 - as one might expect especially since the connections on either side went to pins 10 and 12.

Well after enjoying the (short lived) success, the problem is back. It happened a few times earlier but I uploaded the code again and/or reset the board and it worked. It always shows gibberish on the screen when the boxes disappear. I don't know what on earth is wrong. Help(again) please! :sweat_smile: =(

And yes I retraced my wiring on the fuzzy photos and in the real world, they are all right.

I suggest that you rework your solder joints on the LCD header strip.

Don

I did them again but still it works sometimes but again it doesn't. For example right now it isn't working but a few moments ago it was. What is wrong with it. Another thing I noticed is that whenever there are black boxes on the display, there is no hope of fixing it. But if gibberish is displayed I can re-upload the code and after a few resets and uploads, it works. The random gibberish only comes up if I wiggle the wires(Oops... :cold_sweat: ). I am not sure about which single wire because I randomly wiggle the wires on the breadboard if it doesn't work :sweat_smile: !