NOTE: I finally got my camera figured out so there should only be 1 or 2 blurry images. On with the Instructable!
LCDs are one of the coolest things to add to any project right now. You can use them to display things from the speed of your bike, to the amount of room being used up on your RAM. This Instructable will give you a general description on how LCDs work, and how to get started using them. The information provided here will give you enough information to even develop control circuits on any Microcontroller. LCDs are a lot simpler than you think!
Step 1: How They Work
Most LCDs have a HD44780 LCD driver in them. The HD44780 is the most common LCD driver and is very easy to connect to. A LCD with this driver typically has 14 or 16 pin, with the first being ground and the second being 5V+. This is the only LCD type I will cover today being it is so common. Very common. LCDs of this type are parallel devices. That means that 8 bits of data are sent side by side (or parallel to each other) instead of in line. This is also the way parallel printer ports work which is why it such a popular decision to connect a LCD to a parallel port. Data is sent to LCD screens in a kind of 8-bit Binary ASCII code. For example: 01000001 translates to a capital a. 01000001=A. There are special symbols too like: 11110100=the Pi sign. In the instance of HD44780 driven LCDs, the first bit of data is the 14th pin and the last bit of data is the 7th pin. Unless you haven't figured it out already, this means that building a test rig, or interfacing to a microcontroller would be very simple.
Step 2: Building a Test Rig
Based on the previous information, I will show you how to make a very simple manual LCD test rig that allows you to enter text and symbols which in turn teaches you exactly how they work. Below is the schematic. The jumpers (switches 1-8) have pull-up resistors so that a missing jumpers gives a logic 1 or high.
printed circuit board with individual contacts
10 4.7k resistors
14 wire ribbon cable
any wire to use for wire jumpers
pushbutton momentary switch
2x8 jumper assembly (an eight switch DIP switch would be better. I recommend that actually)
1 wire for power and 1 for ground to your LCD
LM7805 5v DC regulator (or other 5v regulator)
2 small alligator clips
9V battery clip
Optional if you have an LCD wired to a male parallel port:
female parallel port
Helping hand (optional but very useful)
Step 3: Wire the Jumpers
Solder your jumper assembly to the board leaving a little bit of room for other components. Solder together the first line. This will be you ground line.
Step 4: Add the Switches
There are 2 switches in this testing circuit. The first is a SPST switch connected to the Register Select line of the LCD. This switch is used to tell the LCD whether you are sending a command or a character signal. The second is a momentary switch connected to the Enable line. This switch is used tell the LCD to accept the command. Both switches will have pull-up resistors.
Step 5: Resistors
Each jumper and each switch has a 4.7k pull-up resistor. This is so that any closed circuit through a jumper or switch generates a logic 0 (or low). leave a space between each switch/jumper and its resistor. This space is where you will put your ribbon cable connecting the LCD. One side of the line of resistors should be connected together. This will be the positive rail.
Step 6: Contrast and R/W
On my LCD I have already wired it up for parallel connection, so the contrast adjustment is on the screen. If your LCD is not hooked up to anything, this potentiometer is here to adjust the contrast. I have no completely wired it as I have no use for it as of yet, but here is how it goes together. The slider pin should be connected to the wire that will go to pin 3 of the LCD. The other two ends should be connected to 5V+ and Ground. OH yeah, the potentiometer is 10k. The only reason I used a slide potentiometer is because I liked it. You can use a rotational one. Lastly, the R/W connection will be connected to ground, so ad a jumper wire from the ground rail for the pin 5 R/W line on the LCD.
Step 7: Power
Now for the power. LCDs of almost every kind run off five volts DC. for convenience, we will use a 9 volt battery. Solder the ground wire of the 9V battery clip to the ground rail by the jumpers, solder the positive wire a little distance away. Solder the left pin of the 5V regulator (input pin) to the positive wire from the battery clip. This should be the only connection to the positive battery clip wire. Solder a jumper wire from the middle pin of the regulator (ground) to the ground rail. Next solder a jumper wire from the right pin of the regulator (output) to the positive rail. Now it is time to build the alligator clips. solder one clip to the wire for positive and the other to the wire for ground. I mentioned these wires in the parts list. They have nothing to do with the battery clip. solder the positive wire to the positive rail and the ground wire to the ground rail. You will use these alligator clips to power the LCD screen. If you like you could send the power over the ribbon cable to the LCD. Pin 1 on the LCD is ground and pin 2 is Positive. Some LCDs have a 2x7 or 2x8 connection (depending on whether you have a 14 or 16 pin model). You can identify pin one simply since it its ground. It will generally have a thicker PCB trace and connect to the metalwork at some point.
Step 8: The Connector
Since my LCD is wired to a male parallel port connector, I had to connect my ribbon cable to a female parallel port connector. If you are wiring directly to the LCD, pin 14 will be connected to the first jumper and pin 3 to the contrast. Pin 1&2 will be connected to power. look at the schematic for details. The reason we made the whole thing backwards (if you look at the location of pin on on you LCD which is generally the left pin) was so that when we send signals, we are making them the right way around. Pin 7-14 on the LCD are actually what is backwards. If you want to connect your LCD to a parallel port, you will have to follow the below schematic for this. The schematic is a back view of a male parallel port connector. The connections from the tester to the female parallel port is a mirror image. Either way you connect your LCD, this part is necessary. That space between the resistors and the jumpers/switches is where you will connect the ribbon cable. Pin 14-7 connects to the jumper spaces, Pin 6 to the momentary switch space, and pin 4 to the SPST switch space. Pin 5 is connected to ground, and pin 3 is connected to the slider pin of the potentiometer. IMPORTANT: Those space must be filled in! the jumpers/switches and according ribbon cable wires and resistors should all be connected as one.
Step 9: Finished Test Rig
That's it! You got it built. Go on to the next step to learn how to use it.
Update 06/13/2008: I added some pictures of a miniature LCD tester that fits in an Altoids tin. This tester has no contrast control. I will simply solder contrast to ground during tests.
Step 10: Using the Test Rig
As I mentioned in step one, LCDs use a 8-bit ASCII code. To use this tester, first connect the LCD and then the power. Oh no it's broken! There's a bunch of black squares! Don't panic. Those square are supposed to be there, that means it's on. Those squares (technically rectangles but oh well) mean the LCD is on but not yet activated. To activate it we must send a signal that tells the LCD to turn on, give a cursor, and blink for good measure. How do we do that? Easy. First set the Register Select switch to Command mode (the switch is on/logic 1). This is so the LCD knows we are sending a command and not a letter(character mode). Now on the line of jumpers, any removed jumper represents a 1, and any connected jumper represents a 0. The code for what I described earlier is 00001111 (A full list of commands is below). So the first 4 jumpers should be connected. and the last 4 removed. Nothing happened. Nothing should have happened. You should still have black squares. Now you have to tell the LCD to accept the command. Sooo.... HIT THE BIG RED BUTTON!!! Okay, not really, but you can imagine. push the momentary switch. Hey, there's a cursor, now I want some letters. Alright, that's easy. switch the Register Select switch to character mode (the switch is off). Now will send the letter A in capital. The code for capital a (A) is 01000001. Move the jumpers accordingly and hit the button. Hey, Now there's a letter a. A full chart of letters and symbols is below. Play around a bit. The Upper bits are the left 4 jumpers and the lower bits are the right 4. When you fill up you screen, you will need to clear it. To do this, switch the tester to command mode and enter 00000001. This is the clear command. don't forget to hit the button! So now you have a simple controller for LCDs and abroader knowledge of LCDs. In the future, I may ad an update on making custom characters, but that's all for now. Hope this helped!
Attached are some videos of initializing, entering text, and clearing.
You might notice that several characters will pop up instead of one when the switch is pressed, to fix this, you need a Debounce circuit. This prevents this from happening by use of 2 NAND gates in a 74LS00 quad NAND gate and a SPDT switch. Below is the schematic.
As for the parallel port, try LCD Smartie. It is a great open source program with a lot of support and great forums. There is an attached video of me using it. The video opens with windows media player.
Second Prize in the
Instructables and RoboGames Robot Contest