Home

Awesome

micropython-lcd

A simple class for controlling the HD44780 in 4 bit mode with the micropython pyboard.

There are no external dependences, the only module we use is the pyboard's pyb.

Micropython Forum thread: http://forum.micropython.org/viewtopic.php?f=2&t=354

Usage

import pyb
from lcd import HD44780

lcd = HD44780()

lcd.PINS = ['Y1','Y2','Y3','Y4','Y5','Y6']

lcd.init()

lcd.set_line(0) # First line
lcd.set_string("ABCDEFGHIJKLMNOP") # Send a string
lcd.set_line(1) # Second line
lcd.set_string("1234567890123456") # Again

pyb.delay(3000) # 3 second delay

lcd.clear() # Clear the display

Pinout

Hookup your LCD like the following.

Pinout photo

PinCodeDescriptionDo what with it
1VSSGNDGround it
2VDD+5V5V please
3V0Contrast (0-5V)*Stick to 0V if you don't have a pot
4RSRegister selectConnect to pyboard, 0 in array
5R/WRead/writeGround it
6EEnableConnect to pyboard, 1 in array
7DB0Data Bit 0Unused
8DB1Data Bit 1Unused
9DB2Data Bit 2Unused
10DB3Data Bit 3Unused
11DB4Data Bit 4Connect to pyboard, 2 in array
12DB5Data Bit 5Connect to pyboard, 3 in array
13DB6Data Bit 6Connect to pyboard, 4 in array
14DB7Data Bit 7Connect to pyboard, 5 in array
15ABacklight +someVMy display is LED, I use 3.3V
16KBacklight GNDGround it

Then the pinout array looks like this

PINS = ['Y1','Y2','Y3','Y4','Y5','Y6']