HD44780 20x4 issue (showing all squares)

altagest:
What i see is just like it's showing every pixel (a bunch of squares). Do i have burned something?

Not likely. You didn't have the right contrast voltage on LCD pin 3. Did you have a potentiometer?

If you don't use this function the default initialization is for a '1-line' display.

In addition to precluding the use of lines 2, 3 and 4 this also changes the contrast. So even if it is adjusted it properly now it will be messed up again when the lcd.begin() statement is added.

Don

Thanks guys!
I've got a trimmer (10KOhms) but i'm having same issue with this code i found on the net and which i think should be correct (it has correct parameters on the constructor and has the lcd.begin statement). This is the code:

#include <LiquidCrystal.h>

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

void setup() {
//here's the lcd.begin for my display (it's a 20x4)

lcd.begin(20, 4);
lcd.print("Hello Arduino!");
}

//let's print time passing by...
void loop() {
lcd.setCursor(0, 1);
lcd.print(millis()/1000);
}

So, i don't think that there is something wrong. Don't think it's a matter of contrast, since i grounded the contrast pin too and gave him directly 3.3V, nor with the trimmer.

Do i have to buy another one? :stuck_out_tongue:

Another tip: do i have to put a resistance on the backlight led or it is already "slowed down"?

altagest:
Don't think it's a matter of contrast, since i grounded the contrast pin too and gave him directly 3.3V, nor with the trimmer.
Another tip: do i have to put a resistance on the backlight led or it is already "slowed down"?

First, provide a picture how you connected the trimmer. Neither grounding the contrast or giving 3.3V was correct.
Second, yes you need 300 ohm to 500 ohm resistor to "slow down" the back light current.

gave him directly 3.3V

Most HD44780-compatible lcds require ~4v (vs. Vdd) on the Vo for the contrast to work - check the datasheet.

For a 3.3v powered-lcd, that means you will need to apply -0.7v to the Vo pin for the display to show anything. That can be easily created by a pwm output on a charge pump circuit (two diodes + capacitors). the pot will be bridged between +3.3v (or gnd) and the output of the charge pump circuit, with the wiper going to the Vo pin. It has the added benefit of being able to software set the contrast.

Most HD44780-compatible lcds require ~4v (vs. Vdd) on the Vo for the contrast to work

You can check this by using a battery to create the negative voltage: put the battery's positive to ground and negative to the Vo pin. You will see very dark displayed on the lcd.

You can check this by using a battery to create the negative voltage: put the battery's positive to ground and negative to the Vo pin. You will see very dark displayed on the lcd.

He is already seeing every pixel very dark which leads me to believe that he doesn't need a negative voltage (w/r to GND) on his display. Connecting the battery as you say won't hurt anything so it's worth a try.

Just to clarify things, you normally connect the ends of your potentiometer to the positive supply (almost always pin2) and GND (almost always pin 1) and connect the wiper to the contrast (pin3).

Until fairly recently most LCDs ran with a +5 V positive supply. Since the contrast voltage should typically be about 4 to 4.5 volts less than the supply voltage this will place the contrast pin between 0.5 and 1 volt above GND.

If your LCD is running from +3.3 V then you may require a negative voltage (w/r to GND) at pin 3. To do this you leave everything connected as described above except for one end of the potentiometer. You disconnect the end of the potentiometer from the GND (pin 1) and connect it instead to the negative end of your battery. You connect the positive end of your battery to GND.

You should see all of the pixels very dark with the potentiometer at one end and you should see a blank display with the potentiometer at the other end. On your 4-row display you should see dim blocks in the first and third row but the second and fourth row should be blank when the contrast is properly adjusted. Don't try to run your sketch until you can get this action, you will be wasting your time.

Don

Man i tried all the stuff above, i even connected the contrast pin to a digital out (pin 9) to select the voltage... like that:

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

and the less value i put like

analogWrite(9, 20);

the bigger the contrast is. If i put analogWrite(9,200) i see like 0 contrast. But i can't see any data, only squares.

I think i burned something (like some driver, if there is any). :frowning:

Let's start all over again.

From your original post:

I'm having a trouble with a 20x4 LCD.

It would help if we knew exactly which LCD you are using. It's part number would be sufficient and a link to it's data sheet would be even better.

Obviously, every connection is made correctly.

This is not at all obvious since your display is not working properly. It is quite possible that you are completely misinterpreting your pin connections, especially if you are using a device with it's row of pins below and to the left of the display. A photograph of your connections would really help here.

From Reply #5:

I've got a trimmer (10KOhms) but i'm having same issue with this code ...

The code that you are using has nothing to do with the ability to adjust the trimmer to set the correct contrast. As a matter of fact you can, and probably should, adjust the trimmer before you ever connect your LCD to your Arduino.

Replies #7 and #9:
Here we are guessing as to what voltage is being used to power your LCD module. Why don't you just tell us?

Reply #10

Man i tried all the stuff above, i even connected the contrast pin to a digital out (pin 9) to select the voltage... like that:

I wasn't aware that you could use Analog write with a digital pin. You cannot get the correct contrast setting this way. With a digital pin the output is either high or low. With the output high your display will be blank and with the output low you will (usually) get dark blocks everywhere. Once again - you should get the contrast adjusted properly before you try to run any code and preferably before you even connect the Arduino. If you want to use PWM to set the contrast then do that later on, after you have the device working.

I think i burned something (like some driver, if there is any).

As long as you are seeing the squares there's a good possibility that your display is still usable.

Don

So, that is what i've done. sorry if it's a little bit confused, but this should clarify what i'm doing.
Let me know what you think!

altagest:
So, that is what i've done. sorry if it's a little bit confused, but this should clarify what i'm doing.
Let me know what you think!

Open -> Liquid Crystal -> HelloWorld

DEAFBOY:

altagest:
So, that is what i've done. sorry if it's a little bit confused, but this should clarify what i'm doing.
Let me know what you think!

Open -> Liquid Crystal -> HelloWorld

Meh, the only thing that changes from what i'm doing, is the 5V+ connected to the potentiometer. So nothing changes. Right?

Meh, the only thing that changes from what i'm doing, is the 5V+ connected to the potentiometer. So nothing changes. Right?

Please rephrase this, I don't understand.

In one photo it looks to me as if your RS, R/W, and E connections are offset by one pin at the LCD end. In another it look like just the E connection is wrong. All of the solder connections are horrible.

Don

Horrible is a compliment. I know it's pitiful. It's a fast prototype, anyway, i'm doing exactly what is in the scheme by DEAFBOY. The only thing that changes, is that i'm taking two wires from the +5V of the Arduino: one to the potentiometer and the other on the supply of the LCD directly. Then it's exactly the same. I double and triple checked the connections and they are correct.

i'm doing exactly what is in the scheme by DEAFBOY. The only thing that changes,

= "I am doing exactly what you told me to do, other than that I am doing none of what you told me to do."

It's a fast prototype, anyway,

It's not really going that fast, is it?

I double and triple checked the connections and they are correct.

I've heard this before.

Please provide a photograph that unambiguously shows the connections between your LCD module and your Arduino. As I said before some of your connections appear incorrect in your previous photos.

Don

altagest:
Horrible is a compliment. I know it's pitiful. It's a fast prototype, anyway, i'm doing exactly what is in the scheme by DEAFBOY. The only thing that changes, is that i'm taking two wires from the +5V of the Arduino: one to the potentiometer and the other on the supply of the LCD directly. Then it's exactly the same. I double and triple checked the connections and they are correct.

I recommend a breadboard and a breadboard friendly potentiometer and jumper wires. Or just get an LCD shield.

I double and triple checked the connections and they are correct.

Some wise guy said a while ago that bugs usually are where you don't expect them to be.

Mmm... yesterday night i posted the images, but for a strange reason i can't find them now. I know it sucks, but if you don't have 10 fingers (and a breadbord) then it's a quite discrete job. I'll get a breadboard and let you know. Dhenry, where you talking about good ol' Edsger?