Memorial day is 05/25/2015 – Orders will ship out on May 26th. There will not be any deliveries or shipping on Monday. Any order placed after 11am ET on Friday May 22nd will not start to ship out until Tuesday May 26th.
The backlights will not turn on until you have the code running so don't be alarmed if nothing lights up when you plug in the plate! If you have a 'positive' style LCD, you may see some squares on the first line, that's normal

Setting up your Pi for I2C

For a more basic introduction to setting up I2C on your Pi then you may wish to take a diversion to this Adafruit tutorial:  http://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup/configuring-i2c

If you're using Occidentalis, you can skip this next step, but for Raspbian users, edit /etc/modules (sudo nano /etc/modules) and add:

i2c-bcm2708
i2c-dev
to the end of the file. Then save and reboot to enable the hardware I2C driver.


Before you can get started with I2C on the Pi, you'll need to run through a couple quick steps from the console.  Just enter the following commands to add SMBus support (which includes I2C) to Python:

Copy Code
sudo apt-get install python-smbus
sudo apt-get install i2c-tools
i2c-tools isn't strictly required, but it's a useful package since you can use it to scan for any I2C or SMBus devices connected to your board.  If you know something is connected, but you don't know it's 7-bit I2C address, this library has a great little tool to help you find it:
Copy Code
sudo i2cdetect -y 0 (if you are using a version 1 Raspberry Pi)
sudo i2cdetect -y 1 (if you are using a version 2 Raspberry Pi)        
This will search /dev/i2c-0 or /dev/i2c-1 for all address, and if an Adafruit LCD Plate is connected, it should show up at 0x20

Once both of these packages have been installed, you have everything you need to get started accessing I2C and SMBus devices in Python.

Using the example Python code

The LCD Pi Plate Python code for Pi is available on Github at: https://github.com/adafruit/Adafruit_Python_CharLCD

Note that this is an updated library which can be installed independently of other Python character LCD code. If you're looking for the older library, it can still be found at its home on GitHub. For new projects try using the newer library described here.

The easiest way to get the code onto your Pi is to hook up an Ethernet cable, and clone it directly using 'git', which is installed by default on most distros. Simply run the following commands from an appropriate location (ex. "/home/pi"):
Copy Code
sudo apt-get update
sudo apt-get install build-essential python-dev python-smbus python-pip git
sudo pip install RPi.GPIO
git clone https://github.com/adafruit/Adafruit_Python_CharLCD.git
cd Adafruit_Python_CharLCD
sudo python setup.py install

Testing the Library

Once the code has be downloaded to an appropriate folder, and you have your LCD Plate properly connected, you can start with the basic demo display, which is run by simply executing the char_lcd_plate.py script in the examples folder:
Copy Code
cd examples
sudo python char_lcd_plate.py
The example will turn the backlight on to different RGB colors (don't worry if you're using a monochrome backlight LCD, it is normal to see the backlight turn on and off) and then ask you to press buttons. As you press different buttons the button name should be printed and the backlight color changed. Try pressing different buttons to see what happens on the display.

Press Ctrl-C to quit the program.

Adjusting Contrast

The plate uses a character LCD with an external contrast potentiometer. The first time you use it, adjust the potentiometer in the bottom right until you see the text clearly. If you don't upload code to the Pi, some boxes may appear instead, or you may see nothing at all.

Using the library code

Look at the contents of the char_lcd_plate.py file to see the basic usage of the character LCD plate class. The basic usage is to import the library and create an instance of the Adafruit_CharLCDPlate class. The char LCD plate class is smart enough to know how to talk to the character LCD plate without any configuration or parameters.

Once you have an instance of the Adafruit_CharLCDPlate class there are a few functions you can call to interact with the display:
  • message(text)
    • Print the provided string message to the display. The text string can include linebreak characters ('\n') and will move to the next line when found in the string.
  • clear()
    • Clear the display and reset the position of message printing to the first column and first line.
  • set_color(red, green, blue)
    • Set the color of the red, green, and blue backlight LEDs. Each color value should be a 1 for on or 0 for off. For example to set a red backlight call set_color(1,0,0) or to set a purple color call set_color(1,0,1).
You can find a more detailed write-up of the library in this character LCD guide (see the Usage and Raspberry Pi Char LCD Plate pages).
Last updated on 2015-05-04 at 04.27.56 PM Published on 2012-11-21 at 02.51.59 PM