I have scrounged up several LCD displays and wanted to use one with the Arduino. At the very least I wanted to test the displays. For future projects with the Arduino having a LCD display could be very handy so for this reason it is a good first project as well.
Unfortunately interfacing an LCD uses up much of the available I/O pins. All the digital I/O pins end up used (except for serial) for an 8-Bit LCD interface. I want to have more then just an LCD to display information. I also want to have buttons for interacting with the Arduino software. The ultimate goal here is to have both an LCD to display data and at least four buttons for interaction. Also, there has to be some I/O left over for interfacing to the application as well.
The answer is to interface the LCD using 4-bit mode and to use the same I/O lines to read four pushbutton switches. When the I/O lines are not used to transfer data to the LCD they can be read to get the state of the pushbuttons. Assuming this multiplexing can be done, there would be some I/O left for projects. Lucky for me there is already a 4-bit LCD interfacing library. After getting the probably easier 8-Bit interfacing working, I plan to change to 4-Bit interfacing as the next step toward the ultimate goal.
I would like to create a standard LCD and Keypad interface with a matching Library for the Arduino. Let me know in the comments if someone has already solved this problem. I know there are serial LCD modules and even some that have integrated buttons but I want to keep the serial port free.
There is a lot of information on the web for interfacing the Arduino to LCD displays. I chose to use the basic 8-Bit library and to follow the LCD interfacing tutorial for my first try at getting an LCD to work. I have several LCD modules that have been scrounged here and there. This easy tutorial should give me a setup to test all my scrounged modules.
You can learn all bout interfacing an LCD to the Arduino with the links below.
From the Arduino playground site. Lots of information and links. Probably the best starting place for information related to Arduino LCD interfacing.
Arduino Liquid Crystal Library Tutorial. This is the best starting point for your first Arduino project.
Datasheet for the Hitachi controller used in almost every text LCD module
Great description of how-to interface LCD displays. Written for PIC microcontrollers as part of an free online book. Excellent source for information.
Initialization is tricky with the Hitachi controller luckily you don’t have to worry about it as the free Arduino library takes care of this. But if you want to know more about this process check this out.
This is the top level LCD page for the link mentioned above. Looks like a valuable resource for interfacing these LCD modules to a PC.
This site looks like a comprehensive source for working with the industry standard Hitachi controller
This short article shows how to interface the Arduino to an LCD without using the existing libraries.
We are talking about the small text LCD displays you see on some devices. These display’s are very common and usually have a standard 14 or 16 pin connection. They use the Hitachi HD44780 or compatible controller and are easy and cheap to get. All Electronics has 16×2 LCD modules for $10/each with LED backlighting and $6/each without.
My first attempt 8-bit interfacing:
The standard 14 pin connector is shown below. Some of the units I have had 16 pin connectors with the extra two used for backlight. The pin-out diagram below shows what I found to be the wiring. I successfully tested several modules with both 14 and 16 pin connectors, all worked with the following pin outs.
4—Register Select (RS)
7—Data Bit 0 LSB (D0)
8—Data Bit 1 LSB (D1)
9—Data Bit 2 LSB (D2)
10–Data Bit 3 LSB (D3)
11–Data Bit 4 LSB (D4)
12–Data Bit 5 LSB (D5)
13–Data Bit 6 LSB (D6)
14–Data Bit 7 LSB (D7)
I had to edit the source for the Arduino 8 bit LCD library. The pinMode, digitalWrite and digitalRead prototypes had to be commented out in the LiquidCrystal.cpp file as they are apparently defined elsewhere with slightly different parameter types.
Other then finding the pin out and the initial problem with the library the only other issue I had was that my LCD modules were very sensitive to the contrast voltage. I used a 100K potentiometer (pot) hooked across 5V to supply the contrast voltage. The voltage needed to be very near 0V to see anything at all.
Once I got the initial setup going I tested every text LCD module I could find. Surprisingly all the modules I have worked. Even a 4 line module seemed to work well.
Plans for Part 2
For part 2 of this article I plan to get the 4-bit mode working and figure out the button interface.