You can use the Pi to drive a Liquid Crystal Display (LCD) to display all sorts of information: it could be date, time, system status, disk utilisation, MAC and IP address, etc.
The most common LCD is one based on the Hitachi HD44780 chip. This is an LCD controller and driver LSI device with embedded fonts and the ability to create custom characters. The LCD module and driver chip are supplied assembled and have a 14 or 16 pin connection to a PIC, Pi, PC, etc. This can be in a single row 1×14 or 1×16 edge connector or 2×7 or 2×8 0.1″ IDC connector. The complete assemblies are easily obtainable and many manufacturers make their own compatible LCDs so that the devices are entirely interchangeable at the control and functional level though not always with the same physical connection.
The HD44780 is the main driver chip but this is limited to two rows of eight characters each and so for larger LCD modules one or more slave Hitachi HD44100 chips are used. These convert the serial data from the HD44780 into parallel for passing to the display.
The circuit I used is the one provided by Matt Hawkins at raspberrypi-spy.co.uk. This uses a 4-bit interface to minimise the number of GPIO outputs required but has to send the high and low bit data in two write operations. I used Ciseco’s Slice of Pi board to expose the appropriate pins but you could just use single patch leads and connect directly to the 26-way header. The circuit diagram is shown here but a table of connections is below if you prefer that type of format. The connections in red are for the LCD’s backlight, if it has one. The 560R resistor is to protect the backlight in the event there is no built-in over-current protection.
I started off with Matt’s program but added a few enhancements so that it calls GPIO.cleanup() at the end to close ports so that you do not see warnings if you run the program subsequently. I also had to add a short delay between telling the device which row I was going to write and actually writing it. Without a delay, the first character was sometimes omitted.
A further improvement is to connect a 10K variable potentiometer between the 0V and +5V lines and connect the output to the contrast pin (LCD pin 3). By varying the resistance between 0V and +5V you can find the optimum contrast for your LCD module. The connections in blue show the amendments to the original circuit.
Connect up the components as shown in the diagram. The table of connections are shown below.
|LCD Pin||Function||Pi Function||Pi Pin||Slice of Pi Pin|
|15||+5V via 560R||P1-02||5V0|
If your display does not have pins 15 and 16 you can ignore the backlight connections.
Download the program to your Pi. The easiest way to do this is to use wget from the Pi command line. This will copy the program to your current directory.
Run the program as root. The program just displays some text on the LCD – it doesn’t ask for any input and runs for about four seconds because of the delays programmed.
sudo python lcd.py
If you would like a program that lets you enter the text yourself, try this.
sudo python writelcd.py