Using the Hitachi LM038 LCD with the Arduino

I recently purchased a few LCD displays from ebay, these were labelled up as Hitachi LM038 LCD Modules. There didn’t seem to be much information out there on the internet about how to use these, so I thought i’d put together a quick how to guide for anyone else who may have purcased one of these. In the example i’m using an Arduino (Atmel ATMega328) for speed and ease of use, however the process would be the same for any micro (PIC or AVR).

The photo above is of the front and rear of the module

The LM038 LCD uses the HD44780 LCD Controller in the FP-80B package, the datasheet can be found here http://www.sparkfun.com/datasheets/LCD/HD44780.pdf

As you can see, there is a 14 pin interface on the left of the module (as seen from the lcd face), below is the pin numbering for these.

 

LM038_PinOutDetail

Pin
Name
Function
1
Vss
Ground (0v)
2
Vdd
+5 Volts
3
V5
Return current for the LCD, should be connected to ground via a resistor as this will control the LCD’s contract. In my example i used a variable restistor, i found that a value of approx 6.5KOhm gave good results
4
RS
Register Select. This pin determines if the data your are about to write to the LCD is a command or data byte.LOW (0) indicates an instruction register (when writing) or an address register (when reading). HIGH (1) indicates that this is a data byte (both read and write)
5
R/W
Read/Write, Set this pin to HIGH (1) to read data from the display. Set this pin to LOW (0) to write data to the display. If you don’t need to read data from the display and will only be updating it, then you can tie this pin to ground.
6
E
Enable pin, This line works to clock in data and commands.
7
DB0
Data Pin, Least significant bit
8
DB1
Data Pin
9
DB2
Data Pin
10
DB3
Data Pin
11
DB4
Data Pin
12
DB5
Data Pin
13
DB6
Data Pin
14
DB7
Data Pin, Most significant bit

 

The pin mappings between the LCD module and the Arduino should be as follows

 

LCD Pin
Arduino Pin
1
GND
2
+5V
3
GND via Restistor for contract control
4
12
5
6
6
11
7
2 (Optional)
8
3 (Optional)
9
4 (Optional)
10
5 (Optional)
11
7
12
8
13
9
14
10

 

As you will notice, LCD pins 7,8,9 & 10 are optional more on this later. Luckily the arduino has a library called LiquidCrystal that is compatible with the HD44780 controller, so we will use this for the example. If you are using a the raw Amtel AVR or PIC microcontroller then you will need to refer to the datasheet for the protocol, or possible inspect the LiquidCrystal arduino library (they are all written in C so they are quite portable, albeit designed for usin on an AVR micro).

Here is the hello world code

#include <LiquidCrystal.h>

/* LiquidCrystal display with:
LCD 4 (RS) to arduino pin 12
LCD 5 (R/W) to arduino pin 6
LCD 6 (E) to arduino pin 11
*/
LiquidCrystal lcd(12, 6, 11, 2, 3, 4, 5, 7, 8, 9, 10);

void setup()
{
   // Print a message to the LCD.
   lcd.print("hello, world!");
}
void loop()
{
}

As you can see it’s quite simple, if you want to get more details on the LiquidCrystal arduino library, then have a look here http://www.arduino.cc/en/Reference/LiquidCrystal

Now i mentioned earlier that four of the LCD pins were optional, this is because the LCD can be controlled using 4-Bit mode, this is also supported by the LiquidCrystal library and the code to do this is below, essentially the only change is to the constructor of the LiquidCrystal object.

#include <LiquidCrystal.h>

/* LiquidCrystal display with:
LCD 4 (RS) to arduino pin 12
LCD 5 (R/W) to arduino pin 6
LCD 6 (E) to arduino pin 11
*/
LiquidCrystal lcd(12, 6, 11,7, 8, 9, 10);

void setup()
{
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop()
{
}

Here are a couple of photos of the working LCD

LM038_HelloWorldNarrow

LM038_HelloWorldWide

Yes that is an Acorn Electron in the background 🙂 part of a long term project of mine.

I hope this is useful to anyone else who may have got some of these LCD’s from ebay. (Sorry to the PIC or AVR people, especially the Assembler guys but you should be able to translate from the arduino code into whatever platform you are using).

About author View all posts

Avatar photo

M0YOM

I'm James, a radio amateur, software engineer and professional geek. I'm the IT Director for a software company and Director and part owner of a web design, hosting and media business.

1 CommentLeave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *