Page 1 of 1

Basic LCD driver class (HD44780)

Posted: Wed Oct 22, 2014 6:39 pm
by wjdp
I've put together a very simple class to get a 4-bit LCD up and running quickly. Code based on this RPi version http://www.raspberrypi-spy.co.uk/2012/0 ... ng-python/.

Usage

Code: Select all

    lcd = HD44780()

    # Pins 0-5 as above
    lcd.PINS = ['Y1','Y2','Y3','Y4','Y5','Y6']

    # Initialise display
    lcd.init()

    # Use it
    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

    # Done
    lcd.clear()
https://github.com/wjdp/micropython-lcd

Re: Basic LCD driver class (HD44780)

Posted: Wed Oct 22, 2014 9:11 pm
by dhylands
I also have some code over here: https://github.com/dhylands/python_lcd/tree/master/lcd

It supports 4-bit and 8-bit, as well as some of the I2C based LCD backpacks.

The lcd.py is the generic code.

The pyb_gpio_lcd.py and pyb_i2c_lcd.py create classes derived from LcdApi that takes care of actually talking to the LCD (over GPIO or I2C)

The i2c_lcd.py code also derives from LcdApi, but its designed for the BeagleBoneBlack, using the user-space i2c driver.

Re: Basic LCD driver class (HD44780)

Posted: Fri Dec 29, 2017 7:17 am
by nikhiledutech
Hey,
I am using STM32F407disc board to interface with LCD. I have initalised the rs,en,rw d0-d7 pins correctly still nothing get written on LCD.

I have given code below.

CODE:
from pyb import Pin, delay, millis
from pyb_gpio_lcd import GpioLcd


#PIN configuration
rs = pyb.Pin('PB1',Pin.OUT_PP,Pin.PULL_UP)
rw = pyb.Pin('PB4', Pin.OUT_PP,Pin.PULL_UP)
en = pyb.Pin('PB5', Pin.OUT_PP,Pin.PULL_UP)
d0 = pyb.Pin('PE8', Pin.OUT_PP,Pin.PULL_DOWN)
d1 = pyb.Pin('PE9', Pin.OUT_PP,Pin.PULL_DOWN)
d2 = pyb.Pin('PE10', Pin.OUT_PP,Pin.PULL_DOWN)
d3 = pyb.Pin('PE11', Pin.OUT_PP,Pin.PULL_DOWN)
d4 = pyb.Pin('PE12', Pin.OUT_PP,Pin.PULL_DOWN)
d5 = pyb.Pin('PE13', Pin.OUT_PP,Pin.PULL_DOWN)
d6 = pyb.Pin('PE14', Pin.OUT_PP,Pin.PULL_DOWN)
d7 = pyb.Pin('PE15', Pin.OUT_PP,Pin.PULL_DOWN)

def test_main():
"""Test function for verifying basic functionality."""
print("Running test_main")
lcd = GpioLcd(rs,en,d0,d1,d2,d3,d4,d5,d6,d7,2,16)
lcd.putstr("It Works!\nSecond Line)
delay(3000)
lcd.clear()

This should print It works and Second Line but nothing gets printed on LCD display. So please help me in this. And guide me, if i have to make any changes in my code.

Thank you. :)

Re: Basic LCD driver class (HD44780)

Posted: Fri Dec 29, 2017 3:12 pm
by dhylands
How is your contrast pin (pin 3 on the LCD modules) connected?

Do you see a row of black squares when you power on the LCD? If you don't see the row of black squares, then you need to adjust the contrast voltage until you do. Otherwise, even if everything is working perfectly, you won't see anything on the screen.

Re: Basic LCD driver class (HD44780)

Posted: Mon Jan 01, 2018 4:36 am
by nikhiledutech
When i powered on the LCD it shows black square are displayed on the LCD. After i initialize the LCD, the black boxes get disappeared.