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 | Level | Description |
---|---|---|---|
1 | VSS | 0V | Ground |
2 | VDD | 5.0V | Supply voltage for logic |
3 | VO | --- | Input voltage for LCD |
4 | RS | 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 number | Raspberry Pi header pin | Description |
---|---|---|
1 | GND | Ground |
2 | +5V | Supply voltage for logic |
3 | 10k potentiometer | Adjusts contrast for LCD. Other end of pot to GND |
4 | GPIO 25 | RS |
5 | GND | RW |
6 | GPIO 24 | Enable signal for KS0076 |
11 | GPIO 21 | Data bit 4 |
12 | GPIO 17 | Data bit 5 |
13 | GPIO 21 | Data bit 6 |
14 | GPIO 22 | Data bit 7 |
15 | +5V | Back light anode |
16 | GND | Back light cathode |
Software
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:
- cd ~/
git clone github.com/adafruit/Adafruit_Python_CharLCD.git
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 setup.py 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/
nano char_lcd.py
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