==== Soldering up a 'shield' ====
This tutorial will show you how to solder together a shield for an LCD with a 8x2 header
==== What you'll need ====
|[[http://www.ladyada.net/images/parts/attiny2313dip.jpg|{{ http://www.ladyada.net/images/arduino/diecimilla.jpg?nolink&230x172 |}}]]|Assembled Arduino board, preferrably a Duemilanove, or Diecimila (or whatever the latest version is) but NG is OK too |[[http://www.adafruit.com/index.php?main_page=product_info&cPath=17&products_id=50|Adafruit]] \\ $30|
|[[http://www.ladyada.net/images/parts/10MHzcermosc.jpg|{{ http://www.ladyada.net/images/arduino/usbcable.jpg?nolink&232x174 |}}]]|USB Cable. Standard A-B cable is required. Any length is OK. |[[http://www.adafruit.com/index.php?main_page=product_info&products_id=62|Adafruit]] \\ Or any computer supply store \\ $5|
|{{ http://www.ladyada.net/images/parts/header8f_t.jpg?nolink&150x112 |}}|2 pieces of 7-pin female header (you can always cut down longer header)|Any electronics supply store / $3|
|{{ http://www.ladyada.net/images/parts/headerm36_t.jpg?nolink&200x84 |}}|2 pieces of 7-pin male header (you can always cut down longer header).|Any electronics supply store \\ $0.50|
|{{ http://www.ladyada.net/images/pshield/protoshield_t.jpg?nolink&150x115 |}}|Arduino Prototyping Shield kit, without breadboard! \\ |[[http://www.adafruit.com/index.php?main_page=product_info&cPath=17&products_id=51|Adafruit]] \\ $15 \\ |
|{{ http://www.ladyada.net/images/arduino/lcdtut/lcd_tiny.jpg?nolink&150x58 |}}|Character LCD with parallel interface|Pretty much any online electronics shop!|
|{{ http://www.ladyada.net/images/tools/100ftsolid_t.jpg?nolink&150x150 |}}|Hookup Wire \\ Make sure its //not// stranded wire!|Any hardware store |
==== Annie, get yer LCD ====
The first step is to get the LCD you want. Parallel LCDs come in a couple different sizes, from 16 characters, 1 line (16x1) to 24 characters, 4 lines (24x4).
[[http://www.ladyada.net/images/arduino/lcdtut/lcd.jpg|{{ http://www.ladyada.net/images/arduino/lcdtut/lcd_t.jpg?nolink&500x195 |}}]]
In this tutorial I use the [[http://www.jameco.com/webapp/wcs/stores/servlet/ProductDisplay?langId=-1&storeId=10001&catalogId=10001&productId=365982|16x2 Picvue from Jameco]] because thats what was I had in my box of stuff, but you can easily adapt it for any other LCD. The wiring may differ a little bit but that will be covered.
==== Check out the pins ====
The first step is to turn over the LCD and check out the pins. Parallel LCDs almost always have 14 or 16 pins. In this model they are all the way to the left, near the label J1. I soldered 2 7-pin female headers for e-z plugging. Somtimes the pins are along the bottom all in a row.
[[http://www.ladyada.net/images/arduino/lcdtut/lcdrev.jpg|{{ http://www.ladyada.net/images/arduino/lcdtut/lcdrev_t.jpg?nolink&500x212 |}}]]
Look closely at the header for the numbers that show which pins are which. In this model, the first pin is at the top right, the second pin is top left, etc till pin 14 in the bottom left.
[[http://www.ladyada.net/images/arduino/lcdtut/lcdpins.jpg|{{ http://www.ladyada.net/images/arduino/lcdtut/lcdpins_t.jpg?nolink&500x408 |}}]]
When the LCD is flipped over, the pinout will be //mirrored//**, **to help me keep track of it, I made a diagram:
^**1**^**2**^
^**3**|**4**|
^**5**|**6**|
^**7**|**8**|
^**9**|**10**|
^**11**|**12**|
^**13**|**14**|
Whatever your pinout is, make sure you have a diagram written out since you will need to refer to it many times!
==== Header up! ====
[[http://www.ladyada.net/images/arduino/lcdtut/headersprep.jpg|{{ http://www.ladyada.net/images/arduino/lcdtut/headersprep_t.jpg?nolink&500x370 |}}]]
OK now that we are diagrammed out, I took the protoshield and soldered 2 7-pin headers at one end of the pcb. Note that they are not all the way to the edge, I left one row of holes so I could easily solder some wires. I also soldered a short piece of header (that comes with the shield kit) at the left so that the LCD will be propped up.
[[http://www.ladyada.net/images/arduino/lcdtut/testfit.jpg|{{ http://www.ladyada.net/images/arduino/lcdtut/testfit_t.jpg?nolink&500x375 |}}]]
You can now do a test fit to verify how it will look. it hangs over a bit but thats OK by me
==== Shave & a haircut - 4 bits! ====
Since this is a parallel LCD, data will be sent to it over a //parallel //interface. That is, multiple bits at a time. These LCDs are designed for either a 8-bit or 4-bit interface. Since we'd like to save pins, lets go with the 4-bit interface! The data pins are name **D4**, **D5**, **D6**, and ** D7**. Double-check your datasheet but almost all parallel LCDs have these pins numbered 4, 3, 2, and 1 respectively.
^**1 (D7) **^**2 (D6)**^
^**3 (D5)**|**4 (D4)**|
^**5**|**6**|
^**7**|**8**|
^**9 (ENABLE) **|**10 (R/W) **|
^**11 (RS) **|**12 (CONTRAST)**|
^**13 (GND/VSS) **|**14 (+5V/VDD) **|
There's a lot of wiring to be done but we're going to go thru it very slowly so it shouldn't be too bad.
Lets connect these to the arduino thusly: D4 -> Arduino pin #7, D5 -> Arduino pin #8, D6 -> Arduino pin #9, D7 -> Arduino pin #10
[[http://www.ladyada.net/images/arduino/lcdtut/datawires.jpg|{{ http://www.ladyada.net/images/arduino/lcdtut/datawires_t.jpg?nolink&500x375 |}}]]
Since I wasnt sure of the wiring, I used the sockets on the protoshield. Once I test and verify they are correct, I'll solder them in!
Next are the two power wires. Parallel LCDs run off of +5V so you can just solder the Vcc wire to 5V and the ground wire to GND.
[[http://www.ladyada.net/images/arduino/lcdtut/powerwires.jpg|{{ http://www.ladyada.net/images/arduino/lcdtut/powerwires_t.jpg?nolink&500x358 |}}]]
Next are the 2 control wires, **ENABLE** and **RS** which we connect to pins 12 and 11 respectively.
[[http://www.ladyada.net/images/arduino/lcdtut/controlwires.jpg|{{ http://www.ladyada.net/images/arduino/lcdtut/controlwires_t.jpg?nolink&500x364 |}}]]
Theres another control line called **R/W** that you can use to control whether you're reading or writing to the LCD. Since we'll just be writing, that pin can be connected to ground, saving another arduino pin
[[http://www.ladyada.net/images/arduino/lcdtut/rwline.jpg|{{ http://www.ladyada.net/images/arduino/lcdtut/rwline_t.jpg?nolink&500x370 |}}]]
The last wire is the contrast control, we need to connect a potentiometer to this to make the display visible. I dont know the specifics of the input current but I used a 10K potentiometer and it worked great.
One pin is connected to +5V, the pin on the other side is connected to ground and the middle pin is connected to the contrast line.
[[http://www.ladyada.net/images/arduino/lcdtut/contrastpot.jpg|{{ http://www.ladyada.net/images/arduino/lcdtut/contrastpot_t.jpg?nolink&500x349 |}}]]
Now place the LCD on top. Looks good!
[[http://www.ladyada.net/images/arduino/lcdtut/lcdplaced.jpg|{{ http://www.ladyada.net/images/arduino/lcdtut/lcdplaced_t.jpg?nolink&500x306 |}}]]
Make sure you finish up the rest of the shield so you can plug it into an arduino. At least solder in the male headers.
==== Test1 ====
Our first test will be just to connect it up to power and see what happens. Plug it into an Arduino and power it up. You should see the following:
[[http://www.ladyada.net/images/arduino/lcdtut/lcdstart.jpg|{{ http://www.ladyada.net/images/arduino/lcdtut/lcdstart_t.jpg?nolink&500x322 |}}]]
Make sure you tweak the contrast potentiometer, if the contrast is all the way down you may not see anything
==== Froots! ====
Now we must upload some sketch to the Arduino to talk to the LCD. Luckily the **LiquidCrystal** library is already built in. So we just need to load one of the examples and modify it for the pins we used
If you've changed the pins, you'll want to make a handy table so you can update the sketch properly
|**LCD pin name**|RS|EN|DB4|DB5|DB6|DB7|
|**Arduino pin #**|11|12|7|8|9|10|
Open up the** File->Examples->LiquidCrystal->HelloWorld **example sketch
Now we'll need to update the pins. Look for this line:
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
And change it to:
LiquidCrystal lcd(**11, 12, 7, 8, 9, 10**);
To match the pin table we just made.
Now you can compile and upload the sketch, adjusting the contrast if necessary. (The image below is from a different fruity sketch but it will look similar)
[[http://www.ladyada.net/images/arduino/lcdtut/pineapple.jpg|{{ http://www.ladyada.net/images/arduino/lcdtut/pineapple_t.jpg?nolink&500x303 |}}]]
Hooray! You're ready to start printing your own messages.