C – Adams Bros Blog http://blog.adamsbros.org Tue, 16 Jun 2009 04:54:18 +0000 en-US hourly 1 https://wordpress.org/?v=5.2.2 arduino interfacing with the HD44780 LCD http://blog.adamsbros.org/2009/06/15/arduino-interfacing-with-the-hd44780-lcd/ http://blog.adamsbros.org/2009/06/15/arduino-interfacing-with-the-hd44780-lcd/#comments Tue, 16 Jun 2009 04:54:18 +0000 http://blog.adamsbros.org/?p=60 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

ArduinoLCD_back

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:

http://www.shopeio.com/inventory/pdf/AMC2004A.pdf
http://arduino.cc/en/Reference/LiquidCrystal

#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

ArduinoLCD_finished

#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
lcd.setCursor(3,2);
// Print a message to the LCD.
lcd.print(“hello, world!”);
}

void loop()
{
}
]]>
http://blog.adamsbros.org/2009/06/15/arduino-interfacing-with-the-hd44780-lcd/feed/ 5