This repository contains a MicroPython library for commanding a HD44780 Liquid Crystal Display (LCD) controller via a PCF8574T GPIO expander. A PCF8574 GPIO expander can be accessed via a I2C bus. This repository includes the library and some example code. The library was developed and tested using a Raspberry Pi Pico.
Using this library you can utilize any of the HD44780 LCD controller instructions indicated below.
HD44780 Instruction | Supported? |
---|---|
Clear Display | ✔️ |
Return Home | ✔️ |
Entry Mode Set | ✔️ |
Display On/Off Control | ✔️ |
Cursor or Display Shift | ✔️ |
Function Set | ✔️ |
Set CGRAM Address | ✔️ |
Set DDRAM Address | ✔️ |
Read Busy Flag & Address | ✔️ |
Write Data to CG/DDRAM | ✔️ |
Read Data from CG/DDRAM | ✔️ |
Initializing By Instruction | ✔️ |
In addition, turning the LCD backlight on and off is supported.
import machine
from PCF8574TonHD44780 import PCF8574TonHD44780
sda = machine.Pin(0)
scl = machine.Pin(1)
i2c = machine.I2C(0, sda=sda, scl=scl, freq=400000)
lcd = PCF8574TonHD44780(i2c, 0x27, True)
lcd.initialize_lcd()
lcd.display_off()
lcd.clear_display()
lcd.cursor_on(False)
lcd.reset_cursor_pos()
lcd.set_entry_mode(True, False)
lcd.set_cursor_pos(4, 1)
lcd.write_str('Hi World!')