HD44780 Text LCD
Controlling text LCD panels, which use the HD44780 LCD display driver.
Hello World
Import programTextLCD_HelloWorld
Simple Hello World! for the TextLCD library
Library
Import libraryTextLCD
TextLCD library for controlling various LCD panels based on the HD44780 4-bit interface
Notes
Pin number | TextLCD pins | mbed pins |
---|---|---|
1 | GND | 0V |
2 | VCC | 3.3V |
3 | VO | 0V, via 1k resistor |
4 | RS | p15 |
5 | RW | 0V |
6 | E | p16 |
7 | D0 | not connected |
8 | D1 | not connected |
9 | D2 | not connected |
10 | D3 | not connected |
11 | D4 | p17 |
12 | D5 | p18 |
13 | D6 | p19 |
14 | D7 | p20 |
Warning
The contrast VO pin seems to have different behaviour on different displays, so you may need to experiment for your display to see anything. I think I've seen some work tied to 0V, some to 3.3V, or with a different resistor.
Adjustable contrast can be achieved with a 10k trim-pot in a voltage divider configuration: one side to Vcc, other side to GND, wiper to VO. Adjust until you see a line of solid squares, then back off until they just disappear.
Some displays need a negative voltage at VO. One side of the trimpot is connected to the negative voltage instead of GND in that case. F.i. a Maxim MAX1044 can be used to generate the negative voltage.
Different LCD Panel Sizes
Setting the type field in the TextLCD constructor allows configuration for the different display panel sizes:
TextLCD::LCD16x2 16x2 LCD panel (default) TextLCD::LCD16x2B 16x2 LCD panel alternate addressing TextLCD::LCD20x2 20x2 LCD panel TextLCD::LCD20x4 20x4 LCD panel
Note: There is now also support for
TextLCD::LCD8x1 8x1 LCD panel TextLCD::LCD8x2 8x2 LCD panel TextLCD::LCD16x1 16x1 LCD panel TextLCD::LCD16x4 16x4 LCD panel TextLCD::LCD24x2 24x2 LCD panel TextLCD::LCD24x4 24x4 LCD panel (for KS0078 controller) TextLCD::LCD40x2 40x2 LCD panel TextLCD::LCD40x4 40x4 LCD panel (two controllers)
You can find the new lib here
For example:
#include "mbed.h" #include "TextLCD.h" TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD20x4); // rs, e, d4-d7 int main() { lcd.printf("Hello World!\n"); }
Enhanced Version of Text LCD
An enhanced forked version of the original Text LCD is here
Reference
The underlying HD44780 chip is a driver used in many LCD character displays. It might sometimes be referred to as Hitachi HD44780U. There are also several compatible clones of this chip in use (eg Samsung KS0066).
- Some of the original details were found at http://www.a-netz.de/lcd.en.php
- http://mbed.org/forum/mbed/topic/195/ covered lots of our discovery
You need to log in to post a discussion
Questions
5 years, 11 months ago