Newbie hwlp with 20x4 LCD

Hi all,

I'm new to the world of Arduino and need some help trying to wire-up and run a 20x4 lcd.

My Equiptment

I have the a Arduino Duemilanove board with the Atmega 328 chip which i have wired up to a JHD-204A LCD.

The first thing i noticed is that my LCD is different to all of the examples shown, as it has a second row of pins on the bottom of lcd

The problems

I have tried using the default lcddisplay 2x16 sketch and library which works fine displaying 2 lines of code. So i know the lcd physically works

I then tried using the LCD4Bit library and example sketch, but all i get are 2 lines of black squares on the 1st & 3rd line, and the compiler didn't show any problem before upload.

I've searched on the forum and on google and i'm struggling to make it work.

The other thing i noticed is that i dont seem to have any sort of back light illuminated.

Help needed

I would be very grateful is someone could send a working LCD4bit (Library & Sketch) that will work with this LCD.

I would also be very grateful uf somone could confirm how the lcd should be wired. I wired it following the 2x16 example, if this is wrong can somebody please confirm how it should be wired. (I guess i'm just a bit unsure as my lcd looks different with 2 lots of pin connectors or weather or not the 2x16 wiring example can be used on this lcd- I used the top pins when i wired it)

Thanks in advance for the help,
Rich.

Here is rougly what my lcd screen looks like. Notice that it seems to have a second rom of pins on the bottom, which is different to the examples i've seen.

I used the top row of pins.

I've noticed several manufacturers are duplicating pins on the top and bottom of the display now. I imagine that this is to make them a bit more flexible. The pinouts are the same and either row of pins can be used.

Yes, the 2x16 pinout is the same as the 4x20 pinout. The only differences I've noticed in this type of display's pinouts is some manufacturers (NewHaven for one) reverse the order of the pins. Best to get a data sheet for your particular display and double check.

Hi Royk,

The screen works using the 2x16 code, but i dont get the backlight working. Do you think the pin that controls the backlight on this may be different.

Any idea where i can check was would cuase the backlight not to work ?

The backlight is usually on pins 15 & 16. I don't remember which is anode (+) and which is cathode(-) but I do believe I read one user's comment that they were reversed on his display. Try reversing them on yours. It's a diode so it won't hurt anything if you hook it up backwards. Do use a series resistor (something around 33 - 47 ohms or so to start if it's too dim decrease the resistor). The backlight is simply a string of LEDs and is not otherwise connected to the display. You would drive it with an output pin on your Arduino -- Arduino output to resistor to anode, cathode to ground.

Thanks RoyK,

I'll try reversing the pins when i get home tonight.

Regards,
Rich.

ribuck:

The screen works using the 2x16 code, but ...

I then tried using the LCD4Bit library and example sketch, but all i get are 2 lines of black squares on the 1st & 3rd line, and the compiler didn't show any problem before upload.

When you get the two lines of black squares it means that you have the power applied and the contrast set properly but the LCD controller has not been initialized properly.

Many of the libraries that are available do not follow the datasheet recommendations to use software initialization or they do not implement that initialization properly.

I suggest you try the latest official LiquidCrystal library (Arduino v0017) and try the accompanying example programs. This library follows the datasheet more closely than all the others and should work for you.

Don

Hi Royk,

The contrast control as exactly as you said, pins 15&16. The example diagram for the 2x16 does not show pins 15&16 being used so natrually followling the diagram i didn't wire them in.

Put them in with a Pot to vary the contrast, which seems to be working well.

Now all i need to do is find some help with the LCD4bit not working on the display.

Don,

I've been following the examples online, maybe i'm just following the wrong one. Do you have a link to the one i should be using

Rich.

Use the one from the menu of the IDE 17 (File>Examples>LiquidCrystal>HelloWorld, modified to 4x20:

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

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

void setup() {
  // set up the LCD's number of rows and columns: 
  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);
}

I have the same LCD and the 2 last pins are +5V and GND for the backlight. If you want to control it by software, use an Arduino pin istead of +5V.

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

Hi Tep,

Thanks a bunch, your code worked a treat. it seems that the other examples were missing the pin initialization information and that's why it didn't work.

;D ;D ;D ;D ;D ;D

Hi, does anyone know if the lcd library can be used with a tm402cd lcd display? it's a 2 by 40 character display that I was told has the same driver as the HD44780 lcd. I can power it properly, it goes blank when the program loads (hello world), then it goes back to full bars and no "hello world" displayed. Can someone help me??

Tanx,

marsbar

Hi Marsbar,

When you say it goes to full bars, do you mean ?

I had an issues where i got the lines of black squared on lines 1 & 3 of the LCD which meant it wasn't initializing the screen. which i suspect is the same for you.

Make sure you have the lcd initialized with the following code, and just make sure the pins defined match the input/output pins you are using ?

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

There is BIG problem in LiquidCrystal library... take carefully the pinout. Use D4-D7, not D0-D3 like it is in text.

Other problem was that LiquidCrystal initialize the display like (16,1), my display didnt want to switch to 16x2 when reinitialized (lcd.begin(16,2);).

Look to the datasheet how to initialize the display and check the LiquidCrytal initialization

Jan

I'm using a 16x2 LCD keypad shield, it has been noted that to keep SPI pins free for other stuff (memory card hacks etc) that you should connect the pins and initialise them like so:

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
so thats RS, EN, DB4,DB5,DB6,DB7

btw. LiquidCrystal runs more than adequately in 4bit mode, if you want more control over the lcd use the liquid crystal library, if you want something more lightweight use the LCD4bit library.

Reggie,

are you the same Reggie from SGL ?

Rich.

I certainly am Rich :smiley:

Hi there!
we have those 4x20 displays for a very good price. :slight_smile:

Maybe it can be interesting for you guys!
Regards,
Oldrich

Nice Price, Personally I am looking for a red one if they are around as it's for use in low light conditions where dark adjusted eyes need to be protected, red is the best light for this (no light is best but then you can't see the screen), green/yellow is all I seem to see on the 20x4s.