Having an LCD connected to your Raspberry Pi is impressive and practical. But for a RPi-based device that is working as stand-alone, it is a fundamental element. How else can the user get information or see his/her options?
A cheap and easy to begin with LCD is the HD44780. Actually, the coding is not the LCD itself, but the controller of the display. The display comes both in different sizes:
What is the best choice? Well, for projects that have a menu, such a webradio, the big screen is more convenient. But again it's more expensive ($6-12 USD, 5-8€). The popular 16x2 is cheaper ($3-6USD, 2-5€) and more suitable for status messages (such as IP address, temperature etc.).
When you order it, don't forget to mention the back-light color that fits you best (I prefer the blue one).
So what is the next step after acquiring it? Wiring it of course. As you will see in the top left side of the LCD, there are 16 pins. But don't worry, you won't be needing them all. Here's an overview:
Here's how you will connect the LCD with the potentiometer as you look at it from the back side (not viewing the knob):
When you manage to do the above and you power on the Raspberry, you should see something like this:
So you will see the first line of the LCD with block characters. When adjusting the potentiometer, you should be able to adjust the visibility/blurriness of these blocks. That means: so far so good!
The next steps is to wire the remaining pins, which are pins 4 (RS), 6 (EN) and the first 4 data pins from the LCD (pins 7-10). Make sure you write down what pin from the LCD goes to what pin from the Rapsberry!A useful Excel file to note is this.
In the next article about the HD44780 I will go into details about programming it. If you can't wait and want to play with your newly wired LCD, try the Python code from Adafruit here. Don't forget to change the pin numbers with the ones that you used!
A cheap and easy to begin with LCD is the HD44780. Actually, the coding is not the LCD itself, but the controller of the display. The display comes both in different sizes:
- 2 lines by 16 characters
- 4 lines by 20 characters
- other, non popular dimensions
the largest version of HD44780 with blue back-light |
the popular 2-lined version with green back-light |
When you order it, don't forget to mention the back-light color that fits you best (I prefer the blue one).
So what is the next step after acquiring it? Wiring it of course. As you will see in the top left side of the LCD, there are 16 pins. But don't worry, you won't be needing them all. Here's an overview:
- Generally the first two and the last two pins are about powering the LCD. The first set (pins 1-2) is about the display of characters and the last set (pins 15-16) is about the back-light. When powering, we mean the +5V pin from Raspberry Pi, not the +3.3V one.
- Pins 1, 5 and 16 are all connected to ground (-). Pin 5 is ground because we only want to write to the screen (0), not read (1).
- Pin 3 is about managing the contrast. Here we connect a potentiometer and adjust the contrast (must-do, because the default contrast is always not good enough).
- Pins 4 (Register Select or RS) and 6 (Enable or EN) are about controlling the LCD (e.g. clearing the screen, setting the cursor etc.)
- Pins 7-14 are supposed for the characters to be displayed. That's 8 pins if you are going to program it in 8-bit mode, which again means 8 cables to Raspberry Pi, only for the characters! But we can do with less, meaning only with 4 cables (4-bit mode). It's slower, but the saving on pins is big.
- Pins 2 and 15 from the LCD connect to RPi pin +5V.
- Pins 1, 5 and 16 from the LCD go to any ground pin on RPi.
- Pins 4 (RS), 6 (EN) and the first 4 data pins from the LCD (pins 7-10) connect to any free GPIO pins (not +3V3/+5V and not ground).
- Pin 3 (contrast) connects to the potentiometer which in turns connects its other two pins to +5V and ground.
Here's how you will connect the LCD with the potentiometer as you look at it from the back side (not viewing the knob):
When you manage to do the above and you power on the Raspberry, you should see something like this:
So you will see the first line of the LCD with block characters. When adjusting the potentiometer, you should be able to adjust the visibility/blurriness of these blocks. That means: so far so good!
The next steps is to wire the remaining pins, which are pins 4 (RS), 6 (EN) and the first 4 data pins from the LCD (pins 7-10). Make sure you write down what pin from the LCD goes to what pin from the Rapsberry!A useful Excel file to note is this.
In the next article about the HD44780 I will go into details about programming it. If you can't wait and want to play with your newly wired LCD, try the Python code from Adafruit here. Don't forget to change the pin numbers with the ones that you used!
Good post , it will be very useful to create a raspberry pi web radio..
ReplyDelete