arduino interfacing with the HD44780 LCD

It became time for me to interface an LCD with my Arduino.  I need to generate a handy report of what my various sensors are picking up.  The following is an account of my notes on twisting up my HD44780 compatible LCD on the Arduino. Please enjoy.

I’m staring at my LCD module.  I can hear it saying, “hook me up!”, but I’ll have to read a bit first.

#1: Identification


On the back of the unit, it says:
AMC2004A-B-B6NTDW-SP LOT#000542

A little Googling for “AMC2004A-B” and I find that it’s an HD44780 compatible LCD.  I find a PDF spec sheet and even an Arduino library:

#2: Figuring

The only figuring I need is for the backlight.  The spec says that for the white backlight, I should use 4.0V at 30mA.  I have a 5V supply so, with Ohm’s Law in mind, the math goes:
R   =   V/I   =   Rdrop/series_current   =   (5V-4V)/30mA   =   33Ω

#3: Wiring
A little skimming of the spec sheet helps me understand how to wire this up so here we go:

Pin No. Symbol   Destination   Description
——  ——   ———–   ————————
1          VSS Ground        Ground
2          VDD 5V            Supply Voltage for logic
3           V0 Pot Leg 2     Variable Operating voltage for LCD
4           RS → Arduino 12 Register Selector (H: DATA, L: Instruction code)
5          R/W Ground (Low)  Read/Write Selector (H: Read(MPU→Module) L: Write(MPU→Module))
6            E Arduino 11    Chip enable signal
7          DB0 → No Connection Data bit 0
8          DB1 No Connection Data bit 1
9          DB2 No Connection Data bit 2
10         DB3 No Connection Data bit 3
11         DB4 Arduino  7 Data bit 4
12         DB5 Arduino  8 Data bit 5
13         DB6 Arduino  9 Data bit 6
14         DB7 Arduino 10 Data bit 7
15      LED(+) R2            Anode of LED Backlight
16      LED(-) Ground        Cathode of LED Backlight


#4: Programming

The LiquidCrystal Library came with my Arduino 0012 Alpha software package (IDE).   A couple of modifications to the Hello World Example:

#include <LiquidCrystal.h>

/* LiquidCrystal display with:
LCD 4 (RS) to arduino pin 12
LCD 5 (R/W) to ground (non-existent pin 14 okay?)
LCD 6 (E) to arduino pin 11
d4, d5, d6, d7 on arduino pins 7, 8, 9, 10
LiquidCrystal lcd(12, 14, 11, 7, 8, 9, 10);

void setup()
// position cursor on line x=4,y=3
// Print a message to the LCD.
lcd.print(“hello, world!”);

void loop()