You are viewing an older revision! See the latest version

Text LCD

A driver for Text LCD panels using the 4-bit HD4478 driver.

/media/uploads/simon/textlcdphoto1.jpg

Hello World!

Hello World code for driving a 16x2 LCD panel:

Import program

00001 #include "mbed.h"
00002 #include "TextLCD.h"
00003 
00004 TextLCD lcd(p10, p12, p15, p16, p17, p18); // rs, e, d0-d3
00005 
00006 int main() {
00007     lcd.printf("Hello World!\n");
00008 }

Wiring:

 GND  -- 0v
 VCC  -- 3.3v
 VO   --[ 1k resistor ]-- 0v
 RS   -- p10 
 RW   -- 0v
 E    -- p12
 D0   --
 D1   --
 D2   --
 D3   --
 D4   -- p15
 D5   -- p16
 D6   -- p17
 D7   -- p18

Text LCD Library

Import library

Public Types

enum LCDType { LCD16x2 , LCD16x2B , LCD20x2 , LCD20x4 }

LCD panel format.

More...

Public Member Functions

TextLCD (PinName rs, PinName e, PinName d4, PinName d5, PinName d6, PinName d7, LCDType type=LCD16x2)
Create a TextLCD interface.
int putc (int c)
Write a character to the LCD.
int printf (const char *format,...)
Write a formated string to the LCD.
void locate (int column, int row)
Locate to a screen column and row.
void cls ()
Clear the screen and locate to 0,0.

Different LCD Panel Sizes

Setting the type field int 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 

For example:

#include "mbed.h"
#include "TextLCD.h"

TextLCD lcd(p10, p12, p15, p16, p17, p18, TextLCD::LCD20x4); // rs, e, d0-d3

int main() {
    lcd.printf("Hello World!\n");
}

Reference


All wikipages