Posts tagged with: LCD

Collegare un LCD (HD44780) al Raspberry Pi

Come collegare un display con controller HD44780 alla porta GPIO di un Raspberry.
Dettagli tecnici tratti dall’articolo di Dimitris van Leusden a questo indirizzo.

  • 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.

What/how many pins we need from the RPi side:

  • 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.

Because it’s 8 pins to the Raspberry (+5V, ground, RS, EN and 4 data pins), it’s easy to make a mistake. So my advise is to start simple, and that is to only connect what is related to power and the potentiometer. That means, first connect pins 1,2,3,15 and 16 from the LCD side.

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!