Raspberry Pi 1602 and 2004 LCD Interfacing
Using both 1602 AND 2004 Character LCD Modules with the Raspberry Pi – at the same time!
One of the advantages of character LCD modules is that you control multiple LCD displays with five shared GPIO’s, as long as you have a unique E clock for each LCD.
The lcd_module class takes full advantage of this, and allows you to control as many LCD modules as you can spare GPIO’s for!
To demonstrate this, I connected both the 1602 and 2004 modules at the same time.
They shared RS, D7, D6, D5, D4, but were supplied with a unique E clock.
I could easily control both LCD’s by simply instantiating two LCD objects!
(click on image for larger version)
Sample code:
# initialize an object for the 2004 LCD lcd = lcd_module(2004, 17, 4, 25, 24, 23,22) lcd.disp(0,0,"https:/Mikronauts.com") lcd.disp(0,1,"20x4 character LCD's") lcd.disp(0,2,"make great embedded") lcd.disp(0,3,"status displays!") lcd.dec(lcd.type) # initialize a second lcd object for the 1602 LCD lcd2 = lcd_module(1602, 17, 27, 25, 24, 23,22) lcd2.str("Hello World!") lcd2.dec(lcd2.type) lcd2.disp(1,1,"Dual Screen Pi") # Note how only the E pin was different!
You could easily drive three, four or even more LCD’s if you needed to!
Download
- mikezlcd.py source code for the “lcd_module” python class
- HD44780 data sheet the Hitachi data sheet for the HD44780
Conclusion
Inexpensive character LCD modules are a great way of displaying status information with a Raspberry Pi.
Many data acquisition, robotics and entertainment projects can benefit from such displays – for example, you can use them to display a robot’s heading, voltage readings and much more. Media enthusiasts can use them to display media, volume and artist information from XBMC or other media centre software.
You can even use them in conjunction with an HDMI-connected TV or monitor to provide additional information without using the main display.
The only real limit is your imagination!
Related Articles
- Pi Jumper breakout cable
- SchoolBoard ][ development board
- Raspberry Pi Model B+ Review
- Raspberry Pi USB WiFi Adapter Tests
- Elf: A Raspberry Pi based Robot
Related Links
- https://en.wikipedia.org/wiki/Hitachi_HD44780_LCD_controller
- https://projects.drogon.net/raspberry-pi/gpio-examples/lcd-interface/
- https://www.raspberrypi-spy.co.uk/2012/07/16×2-lcd-module-control-using-python/
- https://www.raspberrypi-spy.co.uk/2012/08/20×4-lcd-module-control-using-python/
- https://www.recantha.co.uk/blog/?p=4849
Article Index: