Pages: [1] 2   Go Down
Author Topic: HD44780 20x4 issue (showing all squares)  (Read 3961 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 46
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello every1!

I'm having a trouble with a 20x4 LCD. I'm doing the simple "Hello world" as following:

Code:
#include <LiquidCrystal.h>

/* LiquidCrystal display with:
LCD 4 (RS) to arduino pin 12
LCD 5 (R/W) to ground (non-existent pin 14 okay?)
LCD 6 (E) to arduino pin 11
d4, d5, d6, d7 on arduino pins 7, 8, 9, 10
*/
LiquidCrystal lcd(12, 14, 11, 7, 8, 9, 10);

void setup()
{
// position cursor on line x=4,y=3
lcd.setCursor(3,2);
// Print a message to the LCD.
lcd.print("hello, world!");
}

void loop()
{
}

Obviously, every connection is made correctly. What i see is just like it's showing every pixel (a bunch of squares). Do i have burned something?

Thanks folks!
Logged

Málaga, Spain
Offline Offline
Edison Member
*
Karma: 41
Posts: 2182
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

No begin nor init. Take a look at the examples that comes with the LiquidCrystal library. They show you how to initialise the LCD correctly. You will then need to adapt it to your particular wiring and LCD.
Logged

   

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 37
Posts: 4330
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
LCD 5 (R/W) to ground (non-existent pin 14 okay?)
It is not OK since pin 14 does exist - it is another way to access the A0 pin when you are using that pin for digital I/O.  If you are grounding pin 5 of the LCD then you should just leave that term out of the list of numbers inside the parentheses.  Look here --> http://arduino.cc/en/Reference/LiquidCrystalConstructor.  

When using the current LiquidCrystal library there is absolutely no benefit in connecting R/W since all the library does in that case is to output a logic 0 to the pin and leave it that way.  If you connect R/W to the Arduino the only thing you accomplish is to unnecessarily tie up one I/O pin.


Quote
No begin nor init.
What FM is saying is that your LCD is not being initialized properly because you have not used lcd.begin().  If you don't use this function the default initialization is for a '1-line' display.

Don
« Last Edit: October 08, 2012, 12:27:00 pm by floresta » Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 73
Posts: 7198
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged


Western New York, USA
Offline Offline
Faraday Member
**
Karma: 37
Posts: 4330
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 46
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

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? smiley-razz

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

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 73
Posts: 7198
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged


Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.

Logged

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 37
Posts: 4330
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 46
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

Code:

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

Code:
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). smiley-sad
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 37
Posts: 4330
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Let's start all over again.

From your original post:
Quote
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.

Quote
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:
Quote
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
Quote
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.

Quote
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

Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 46
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!


* conn1.jpg (138.28 KB, 778x437 - viewed 15 times.)

* conn2.jpg (129.01 KB, 778x437 - viewed 27 times.)

* overall.jpg (231.54 KB, 1037x583 - viewed 21 times.)

* squares.jpg (223.54 KB, 1037x583 - viewed 36 times.)
Logged

Germany
Offline Offline
Jr. Member
**
Karma: 1
Posts: 55
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged


0
Offline Offline
Newbie
*
Karma: 0
Posts: 46
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Pages: [1] 2   Go Up
Jump to: