Interfacing Raspberry Pi to 40 x 2 character LCD display

I recently picked up a Logitek Route 3 Remote Source Selector to use for its 1U rackmount case.  I was pleasantly surprised to find that the unit uses a 40 x 2 character backlit LCD display.  Even better, the display is made by Truly and uses the KS0076B controller IC.  This controller IC is a clone of the Hitachi HD44780 LCD controller.

Download: LCD MODULE MSC-C402DYLY-1N data sheet (PDF File - 1440k)

The pin-outs of this module are the same as most other HD44780 based LCD displays:

Pin NO. Symbol LevelDescription
1 VSS0V Ground
2VDD 5.0V Supply voltage for logic
3 VO---Input voltage for LCD
4RS H/L H : Data signal L : Instruction signal
5 R/W H/L H : Read mode L : Write mode
6 E H H ? L Enable signal for KS0076
7 DB0 H/L Data bit 0
8 DB1 H/L Data bit 1
9 DB2 H/L Data bit 2
10 DB3 H/L Data bit 3
11 DB4 H/L Data bit 4
12 DB5 H/L Data bit 5
13 DB6 H/L Data bit 6
14 DB7 H/L Data bit 7
15 BLA 4.2V Back light anode
16 BLK 0V Back light cathode

To connect this to a Raspberry Pi 3 (or Raspberry Pi 2 and B+) I used the following header pins:

LCD module pin numberRaspberry Pi header pin
1GND Ground
2+5V Supply voltage for logic
310k potentiometer
Adjusts contrast for LCD. Other end of pot to GND
4GPIO 25
6GPIO 24
Enable signal for KS0076
11GPIO 21
Data bit 4
12GPIO 17
Data bit 5
13GPIO 21
Data bit 6
14GPIO 22
Data bit 7
15+5VBack light anode
16GNDBack light cathode


To drive the LCD display via Python you can use the library from Adafruit; To get it installed on your Pi you can use git.  If you don't have git already installed then:

    sudo apt-get update
    sudo apt-get install git

You will also need python and python-dev.  If they are not installed then go ahead and apt-get them as well.

Once that's done, clone the library from Adafruit into your home directory with:

This will clone the repository into whatever directory you are currently in.  Now cd to the cloned directory with:

    cd ./Adafruit_Python_CharLCD

Now run the installer:

    sudo python install

Configuring the LCD library

The LCD library contains a number of examples.  To test that your LCD display is working, edit one of the example programs. eg

    cd ~/Adafruit_Python_CharLCD/examples/

Near the top of the program will be a series of constants that define which GPIO pins you have your display connected to.  Edit these to reflect your wiring configuration.  In my case, this was:

    lcd_rs = 25
    lcd_en = 24
    lcd_d4 = 23
    lcd_d5 = 17
    lcd_d6 = 21
    lcd_d7 = 22

You will also want to configure the column and row parameters to match your display size.  In this case:

    lcd_columns = 40
    lcd_rows = 2

Related articles:

Raspberry PI max7219 8×8 LED Matrix


Midas 16 x 4 LCD display

Although this display uses a driver chip compatible with the usual HD44780 IC, it features slightly different wiring that can catch you out if you are swapping between LCD modules or using the 'normal' 1602 pinouts.

Blackspire Super Pro 22t Chainring

1 x 10 High Range Gearing Options

Update 2018: Garbaruk 10 speed wide range cassettes - complete cassettes made in the fashion of SRAM powerdome.  Smaller cogs machined from steel block and large cog made of aluminium.  These ...

XTR / Dura Ace 9 speed chain

Weighs 289g which is about 45g heavier than the.

Adding gears to a single speed BMX

Why a BMX?