How to connect Arduino with a character LCD

A character LCD can be pretty useful to an Arduino project since Arduino has no display itself. You see them everywhere: vending machines, laser printers, fax machines, etc. You can use the serial port to output information to a PC but that ties the Arduino to a computer. Arduino can do a lot without a PC, taking data and interacting with a user at the same time.

There are many types of LCD, color, mono, dot-matrix, character. A color LCD is always dot-matrix. Some even has touch sensors. We won’t need a color display since information we will display won’t be more useful with a fancy display. The more complex the display gets, the more resources it consumes. An arduino has 20 general I/O lines. A character display uses 6, a dot-matrix display uses 14. In order to use a color dot-matrix display, a microcontroller needs a lot  of memory and send a lot of data to the display, neither of which is what Arduino is best for. The simpler, the better. We will use a mono character display. We need a display for information.

Once in a while you see a teaching equipment company comes up with a handheld all-in-one lab measurement equipment with color display and touch screen. It’s tempting but most of the function it does like spreadsheet, and calculation, can be much better done with even an entry-level netbook. So we’re better off letting what lab equpiment does best, measurement, and leave data analysis to a PC. Enough of unhappy feelings towards teaching equipment companies.

Back to how to hook up a 16 column X 2 row character display.

You can find a very cheap one here:

http://www.dipmicro.com/store/LCD-1602A-Y



Make sure you pick up some male header pins and a 10KOhm potentiometer:

http://www.dipmicro.com/store/HEADS40T

http://www.dipmicro.com/store/R4V10-3386

An LCD has a total of 16 pins. Here is a list of all pins and functions:

Pin 1 GND

Pin 2 +5V

Pin 3 Contrast

Pin 4 RS (Register select)

Pin 5 R/W (Read or write)

Pin 6 EN (Enable signal)

Pin 7~Pin14 D0~D7 (Data)

Pin 15 A (Anode of back light LED)

Pin 16 C (Cathode of back light LED)

Luckly we only need to connect 6 of above pins to Arduino, and 5 additional pins to +5V, ground, or potentiometer.

If you want to do this on a breadboard, you will need some soft jumper wires.

First, you need to solder the male header pins to the LCD. Just break away 16 pins from your 40-pin male header pins, push them through the LCD pin holes and use possibly this iron (http://www.radioshack.com/product/index.jsp?productId=2062758). If you can’t find this in your local store, find a similar one around 30W and a sharp tip.

The LCD won’t stand well on its own with the pins. My trick is to take a piece of eye-glass cleaning cloth, fold it a couple of times, then stick it underneath the LCD as support. First heat up your iron for at least 3 minutes. Then add a little bit of solder to the tip. Wipe excess with sponge. Stick the tip of your iron against the first pin. The first pin takes a while to heat up. Just patiently count to 15. Bring the solder to the pin not the tip of the iron. If the solder melts, good, add around 1/4 inch of solder, wait for the solder to grab on the pin and get sucked in the pin hole. Move on to the next pin. If the solder doesn’t melt, don’t force it against the iron, just wait a few more seconds. When the pin and the hole are both hot enough, the solder will stick or wet them. The curvature is just the opposite when you force melted solder against cold pin.

Finish off all the pins. Check for shorts.

Now push your LCD into your breadboard, keep your Arduino near the LCD. Use a couple of jumper wires, bring the +5V and GND to the breadboard’s power rails. Add the potentiometer near the LCD pin 1. Connect left pin to +5V and right pin to GND. Connect the following LCD pins:

Pin 1 GND

Pin 2 +5V

Pin 3 middle of the potentiometer

This should power the LCD logic and contrast.

Now turn the potentiometer until you can see a row of black boxes on the display. This confirms that your display is working.

Now connect the following LCD pins:

Pin 15 +5V

Pin 16 220 Ohm resistor

The other side of the resistor goes to GND.

This should power up the LCD back light. If the back light is too dim, reduce the value of the resistor. Don’t connect Pin 16 directly to the ground. Doing so will reduce the life time of the back light by a lot. Most spec sheets tell you what to do regarding series resistors on back light. In doubt, try a 150 Ohm. Then gradually dial up or down the number (with a pot) to find the brightness you need.

I would turn my lights off at night and dial the brightness just enough for comfortable viewing in the dark. In this case the back light is not visible in well-lit rooms, which doesn’t need back light in the first place.

Now connect the following LCD pins to Arduino pins:

Pin 4 RS to Arduino digital Pin 7 (green on the left)

Pin 5 R/W to GND

Pin 6 EN to Arduino digital Pin 6 (orange on the left)

Pin 11~Pin14 D0~D7 (Data) to Arduino digital Pins 5~2. (blue, green, orange, white)

From left to right on LCD, black(GND), red (5V), blue (potentiometer middle), green(RS),orange(GND),another orange(EN, sorry running out of jumper wires), not connected (next 4 pins), blue, green, orange, white (D4-D7), red(5V), resistor (to GND)

We don’t need all 8 data pins. The LCD can work at 4-bit data mode, which saves 4 Arduino pins.

Now load the HelloWorld example code in Arduino IDE under examples->LiquidCrystal.

Make sure you change the line with LiquidCrystal(x,x,x,x,x,x); to LiquidCrystal lcd(7, 6,  5, 4, 3, 2);

Compile the sketch and upload it to Arduino. It should show “hello, world” and followed by a second count. If you’ve gone this far, you’ve made it. Go ahead and load more examples and modify them to learn how to work with the LCD. It’s easy, like LCD.print(“This is a message”);

If you want a more permanent installation of an LCD, instead of 12 loose wires, look at my Phi-1 shield. You can directly plug the LCD on the shield to make connection or take it off for a different project.

6 Responses to How to connect Arduino with a character LCD

  1. Sony says:

    thank u very much , good sharing

  2. celem1 says:

    Thanks – made setting it up the 1602A the first time a lot easier.

  3. Pingback: Arduino mit 1602A Flüssigkristalldisplay | weezerle

    • liudr says:

      Google translate for English readers: I’m trying to build me the instructions from Lidur’s Blog

      It’s possible that the person used some instructions on my blog as instructions for their projects 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: