Raspberry Pi Char LCD Plate

The character LCD plate is a great way to add a simple character LCD and buttons to your Raspberry Pi project. Because the character LCD plate is based on the MCP23017 IO expander, the character LCD library easily supports the character LCD plate!

If you aren't familiar with the character LCD plate, make sure to first read the guide on its usage.

To use this character LCD library with the plate, make sure the library is installed by following the steps on the usage page. Then connect the LCD plate to your Raspberry Pi and execute the char_lcd_plate.py script in the library's examples folder:
sudo python char_lcd_plate.py
Note that the example assumes an RGB character LCD is attached to the plate, however it will still run with a monochrome LCD (you just might see the backlight turn on and off in different ways as colors as displayed).

When you run the example you should see the backlight run through different colors, and then the display will tell you to press buttons. If you press different buttons on the LCD plate you should see the button name and a different color displayed. Try pressing buttons to see how the script reacts!

Examine the code for the char_lcd_plate.py script to see how to use the character LCD plate code. The usage of the LCD plate is very similar to RGB or monochrome LCD usage, with a few key differences.

The first difference is that you create and instance of the Adafruit_CharLCDPlate class. You don't need to pass any parameters in to this class' constructor/init function because it is preconfigured for the LCD plate.
# Initialize the LCD using the pins 
lcd = LCD.Adafruit_CharLCDPlate()
The second difference is that the Adafruit_CharLCDPlate adds a function to test if a button is pressed. Notice how the is_pressed function is called for each button, and if it returns True then the button press is detected.

For example to check if the select button is pressed you can call is_presssed(LCD.SELECT), or to check if the right button is pressed you can call is_pressed(LCD.RIGHT).
# Make list of button value, text, and backlight color.
buttons = ( (LCD.SELECT, 'Select', (1,1,1)),
            (LCD.LEFT,   'Left'  , (1,0,0)),
            (LCD.UP,     'Up'    , (0,0,1)),
            (LCD.DOWN,   'Down'  , (0,1,0)),
            (LCD.RIGHT,  'Right' , (1,0,1)) )

print 'Press Ctrl-C to quit.'
while True:
	# Loop through each button and check if it is pressed.
	for button in buttons:
		if lcd.is_pressed(button[0]):
			# Button is pressed, change the message and backlight.
			lcd.clear()
			lcd.message(button[1])
			lcd.set_color(button[2][0], button[2][1], button[2][2])
One final thing to note, just like using an MCP230xx IO extender the character LCD plate does not support PWM control of the backlight LEDs!

That's all there is to using the character LCD plate with the character LCD Python library!
Last updated on 2015-05-04 at 04.27.56 PM Published on 2014-07-22 at 01.35.21 PM