How to use ITEAD's 16x2 character LCD display for Raspberry Pi (v2.0)

How to use ITEAD's 16x2 character LCD display for Raspberry Pi (v2.0)

Small 16x2 character LCD display modules with pushbutton switches, such as the "RPi LCD1602 Add-on" from ITEAD studio, which mount on top of the Rasperry Pi, make it possible to turn to your Pi into a self-contained "appliance" running your custom application which can display sensor readings or other information and which you can interact with by pressing the onboard pushbutton switches.

The RPi LCD1602 Add-on includes features common to many of these display modules - 2 lines of 16 characters, backlight and five pushbutton switches - but it also provides a GPIO passthrough connector and brings out the serial and I2C ports plus ten unused GPIO pins (including the SPI pins) out to "electronic brick" connections for makers - and it's very inexpensive! That's why we chose to resell these display boards - they're an excellent product at a great price and they're ideal for hardware tinkerers.

Just one problem - ITEAD provide limited documentation.  The essential specs, inlcuding schematics are provided, but to get these boards working, there's a lot you need to figure out for yourself.  So here's what you need to do to setup and use these display boards - it's easy when you know how...
 

Installation

To install the hardware, power down your RPi (model A+, B+ or RPi 2), plug the display board into the 40-pin GPIO connector, then apply power to the Pi again.  That's all.  The display should be lit, with the top row showing 16 solid boxes and the second row clear.  If the display is lit but you don't see the solid box characters, try adjusting the display's contrast, using the trimpot located just above the display (you'll need a small screwdriver).
 

Driver software

The RPi LCD1602 Add-on uses a controller compatible with the "industry standard" HD44780 chip; a number of drivers are already available - we just need to adapt one by changing the GPIO pin connections and polarity settings to suit this module.

Adafruit have developed an extensive collection of Python libaries to support their hardware, including HD44780-compatible LCD modules. Their libraries are open source and it's ok for us to adapt them for use with the RPi LCD1602 Add-on as long as we attribute the source to Adafruit, keep the same licence, and make our changes available to the open source community.  So we'll use a modified version of one of Adafruit's Python libraries. Why Python? It's popular, accessible and easy for beginners.

[These instructions assume that you're using Raspbian, as it's the operating system recommended by the Raspberry Pi Foundation, and that you're working at the command (shell) prompt. If you want to set up Raspbian, see my guide here.] 


To begin, ensure that Raspbian distribution is up to date, with:

sudo apt-get update
sudo apt-get dist-upgrade

then press 'Enter' to continue, and then reboot with 'sudo reboot'.

We also need to install some support packages, with:

sudo apt-get install build-essential python-dev python-smbus python-pip -y
 

Change directory to somewhere you have write permission ( 'cd ~' to go to your home directory will do), then download the support code:

git clone https://github.com/gooligumelec/Gooligum-Adafruit_Python_CharLCD.git

Now change into the newly-created directory and run the install script:

cd Gooligum-Adafruit_Python_CharLCD
sudo python setup.py install

 

Example code

The package includes a couple of example programs in the "examples" directory ('cd examples' to go there).

The first runs the display through its paces, displaying text, scolling it, and fading the backlight in and out.

To try it, type:

sudo ./ITEAD-LCD1602_lcd.py
 

The second example shows how to read the pushbuttons, displaying a different message when each of the five buttons is pushed.  The messages are defined in an array in the code (it's easy to spot...), so you might want to change them to something more interesting than "Button one" etc.  By the way, the '\n' in each message string is a line break - if you run the example, then look at the code, it will make sense.

To try it, type:

sudo ./ITEAD-LCD1602_buttons.py
 

The examples are short and reasonably clear, making it straightforward to expand on them, or to pull the routines out to use in your own code.

Good luck!

Posted by David Meiklejohn

Products related to this article

US$0.00
Add to Cart

Related Articles

Setting up a new Raspberry Pi for electronics hobbyists and makers

Installing Raspbian on an RPi and setting it up for electronics / making - with I2C, SPI, SSH and WiFi enabled

2 comments on this article - view comments

1 Comments To "How to use ITEAD's 16x2 character LCD display for Raspberry Pi (v2.0)"

Ken On 30 Jun 2016
Should all this work on a Pi 3 with out any changes? Reply: not tested yet... Reply to this comment

Write a comment

Your Name:


Enter the code in the box below:

Your Comment:
Note: HTML is not translated!
Powered By OpenCart
Gooligum Electronics © 2017