Monday 26 May 2014

Hitachi LM038 LCD with Arduino

I bought 2 Hitachi LM038 LCDs at the car boot sale last weekend (new), wondering if I'd be able to make them work with an Arduino.

It was TOO easy :-)

I had bought 10 rows of 40 Header Pins on eBay, (so called, but actually various odds & sods of shorter lengths of pins) so soldered 2 rows of 7 pins into the LM038

I had also bought some 40 pin Dupont Male to Female Ribbon Cable (Jumper Wires)


I found this very helpful page:

http://www.m0yom.co.uk/index.php/blog/34-general/62-using-the-hitachi-lm038-lcd-with-the-arduino

tried it, and it worked. TOO easy... BUT... What's with his insane pin order?

It was a bit fraught hooking it up!

I noticed that the initialisation in the start of his code was in the same order as his twisted wiring instructions, so I thought I'd try re-ordering the pins in a more sane manner & seeing if changing the initialisation string to match would work too... of course it did! :-)

So now I have:

LCD PinArduino Pin
1GND
2+5V
3GND via Resistor for contrast control
42
53
64
75 (Optional)
86 (Optional)
97 (Optional)
108 (Optional)
119
1210
1311
1412

And I changed my code to:



#include <LiquidCrystal.h>
/*
 * LiquidCrystal display with:
 * LCD 4 (RS)  to Arduino pin 2
 * LCD 5 (R/W) to Arduino pin 3
 * LCD 6 (E)   to Arduino pin 4
 */

LiquidCrystal lcd(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);

void setup()

{

    // Print a message to the LCD.

    lcd.print("hello, world!");

}

void loop()

{

}

No comments:

Post a Comment