LCD 16x2 Screen

We can display text on an LCD screen - it's a great way of showing important information without having to run a full screen and a more convenient method for showing small messages a user might wish to see.

An LCD Screen capable of showing 16x2 characters

Connecting Up The Screen

As well as the the actual screen module we will also need to connect up a potentiometer to allow us to adjust the brightness on the screen.

A potentiometer used to adjust the brightness
We need to connect the following pins on the LCD Screen to the pins on the Raspberry Pi. Due to the limited number of 5v sources and Ground pins you may need to use splitter pins to provide multiple sources, if you are using jumper cables to connect up the screen
LCD Pin Raspbrry Pi Pin
VSS Ground (GND)
VDD 5v
V0 Potentiometer Middle Pin
RW Ground (GND)
E (Enable) GPIO 24
D0 Not Used
D1 Not Used
D2 Not Used
D3 Not Used
D4 GPIO 23
D5 GPIO 17
D6 GPIO 21
D7 GPIO 22
A 5v
K Ground (GND)
Pinout table for the LDC 16x2 Display
Once the screen has been wired up you will probably notice that the backlight on the screen is dipslayed. There are two lines one with dark squares on, you should adjust the potentiometer until these squares are barely visible.

Setting Up The Library (First Time Only)

Download the code by cloning the following Git repository, using the following command
git clone git://
Next we need to install the library
cd Adafruit_Python_CharLCD
sudo apt-get update
sudo apt-get install build-essential python-dev python-smbus python-pip
sudo python install
We can now access the library from whichever directory we are in. This is very useful. This step only needs to be performed the first time that we set up a new computer for use with the LCD 16x2 display.

The Code

We now need to actually display something on the screen. The following code will display the text 'Hello World' across the two lines of characters for 3 seconds and then display the text 'Electro Cat Studios' Accross the two lines.
import time
import Adafruit_CharLCD as LCD

LCD_RS = 25
LCD_EN = 24
LCD_D4 = 23
LCD_D5 = 17
LCD_D6 = 21
LCD_D7 = 22

lcd = LCD.Adafruit_CharLCD(LCD_RS, LCD_EN, LCD_D4, LCD_D5,

lcd.message('Electro Cat\nStudios')
When you have the code and screen set up try running it and check that you see the expected result. You can now add an LCD screen quickly and easily to your projects.

Want to buy the pieces?

Visit out store by clicking on the button below
Buy Now