Das vierte Türchen

In the past three days you have gained basic knowledge about building a small circuit, soldering and commissioning a micro controller. What the Christmas elves have not yet released was peripherals for the micro controller. The Christmas elves want to correct this today and have hidden six components behind four door.

What's inside behind door number 4

Behind door number four are:

  • 3 x HD44780 1602 LCD module display (green lighting)
  • 3 x I2C interface adapters for soldering

You may also need the program libraries for the Arduino IDE LiquidCrystal and or LiquidCrystal_I2C. We'll show you how to do that here

In general, you have three different options for connecting the display to a micro controller, see illustration 1.

 Illustration 1: HD44780 1602 LCD module displays connection options

The first variant, in the picture above, is the original variant with soldered-on pin header (not included). But this also means that at least 6 pins are assigned on a micro controller, more on that in a moment. The other variant is with the soldered-on I2C interface adapter, which can optionally be soldered on at the front or back. Make sure that the four pin headers for connection to the micro controller always point outwards, otherwise the HD44780 1602 LCD module display can be destroyed.

Classic connection

In the classic variant, the LCD display is connected to the micro controller on a total of 6 pins. Figure 2 shows such a connection, where the 10kOhm potentiometer is used for the contrast on the display.

Illustration 2: LCD connection parallel interface


The corresponding code, see
Code 1, is slim and shows the message "LCD-Display without ic2" in two lines.


//-----------------------------------------------------
// LiquidCrystal parallel interface
// Autor: Joern Weise
// License: GNU GPl 3.0
// Created: 24. Nov 2020
// Update: 24. Nov 2020
//-----------------------------------------------------
#include <LiquidCrystal.h> //include the LiquidCrystal library

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
//define LCD pins (RS, E, D4, D5, D6, D7)

void setup() {
lcd.begin(16, 2); //initializes the LCD and specifies the dimensions
lcd.home();
lcd.print(" LCD-Display ");
lcd.setCursor(0, 1);
lcd.print(" without i2c ");
}

void loop()
{

}

Code 1: Simple edition

Incidentally, the count for the cursor position and the line starts at 0, i.e.
lcd.setCursor (0,1);         is the first position in the second line.

Connection with I2C interface adapter

If you want to operate the display with I2C, you must solder the I2C interface adapter to the display. In principle, you can operate up to 8 LCD displays, provided you set different hex addresses using the address pads. Table 1 shows how you have to solder which address pad to get the desired HEX address, see Figure 3. "X" stands for connected, "0" for not connected.

Item

A0

A1

A2

Hex address

1

X

X

X

0X20

2

0

X

X

0X21

3

X

0

X

0X22

4

0

0

X

0X23

5

X

X

0

0X24

6

0

X

0

0X25

7

X

0

0

0X26

8

0

0

0

0X27

table 1: Hex address for address pads

 Illustration 3: Position of address pads to change the HEX address

The base address is 0x27, all three solder bridges are open.

The connection to a e.g. Uno R3 is quite simple, since the I2C pins of the micro controller are used, i.e. SDA to A4, SCL to A5, VCC to 5V and GND to GND, see Figure 3. Here in Figure 3 the potentiometer for the contrast of the LCD can also be seen well.

 Illustration 4: Connection of HD44780 1602 LCD with I2C to Uno R3

Code 2 also outputs a message on two lines; here it is the phrase "LCD display with i2c". Here we use the second library for LiquidCrystal with the addition _I2C.

//-----------------------------------------------------
// LiquidCrystal I2C connection
// Autor: Joern Weise
// License: GNU GPl 3.0
// Created: 24. Nov 2020
// Update: 24. Nov 2020
//-----------------------------------------------------
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display

void setup()
{
lcd.init(); // initialize the lcd
lcd.backlight(); // backlight on

lcd.home(); // set cursor to 0,0

//Write some text
lcd.print(" LCD-Display ");
lcd.setCursor(0, 1);
lcd.print(" with i2c ");

}

void loop()
{

}

Code 2: Simple output via i2c

Of course, a combination of both connection variants is also possible, for this you have to combine the circuits of Figure 2 and Figure 4 and of course include both libraries.

In this sense….

Figure 5: We wish a merry christmas

You have now put door number 4 into operation and gained a little background knowledge. If you want project ideas, here are some projects:

You can find more projects for AZ-Delivery from me at https://github.com/M3taKn1ght/Blog-Repo.

The AZ-Delivery team wishes you a nice Advent season

Specials

3 comments

Yannic Thiel

Yannic Thiel

Guten Tag
Ich bin absoluter Neuling im Bereich Arduino und Co. Ich hangele mich derzeit von Forum zu Forum und kleine, einfach Programme zum laufen zu bekommen. Ich habe aber ein Problem, dass mich seit Freitag Abend beschäftigt und ich keine vernünftige Lösung dazu finde. Wie kann ich Text, der länger als 16 Zeichen ist, durchscrollen lassen?

Bernd Albrecht

Bernd Albrecht

Unser französischer Freund fragt nach Unterschieden bei den Programm-Bibliotheken und wie man die tatsächliche I2C-Adresse eines Bauteils überprüft.
1. Der einzige Unterschied, den ich festgestellt habe, war bei der Initialisierung des Display-Objekts lcd. Wer bei lcd.init() eine Fehlermeldung erhält, sollte es mit lcd.begin() probieren.
2. Zur Überprüfung der I2C-Adresse benötigt man einen Micro Controller, auf dem die Programm-Bibliothek SoftwareSerial funktioniert, z.B. unseren Nano, sowie einen geeigneten Sketch, z.B. aus unserem Blog-Beitrag vom 5. Oktober 2020: https://www.az-delivery.de/en/blogs/azdelivery-blog-fur-arduino-und-raspberry-pi/ein-praktischer-und-kostengunstiger-i2c-scanner.
Notre ami français demande quelles sont les différences dans les bibliothèques de programmes et comment vérifier l’adresse I2C réelle d’une pièce.
1. La seule différence que j’ai remarquée était l’initialisation de l’objet d’affichage lcd. Si vous obtenez un message d’erreur avec lcd.init (), vous devriez essayer lcd.begin ().
2. Pour vérifier l’adresse I2C, vous avez besoin d’un microcontrôleur sur lequel fonctionne la bibliothèque de programmes SoftwareSerial, par ex. notre nano, ainsi qu’un croquis approprié, par ex. de notre article de blog du 5 octobre 2020: https://www.az-delivery.de/en/blogs/azdelivery-blog-fur-arduino-und-raspberry-pi/ein-praktischer-und-kostengunstiger-i2c-scanner.

Reitzer

Reitzer

Bonjour, merci pour votre partage!
Je démarre dans le “hobby” Arduino et il est difficile pour moi de savoir si toute les bibliothèques “LiquidCrystal_I2C.h” sont équivalentes (en fonction des auteurs) ou non, comment les choisir et ou les trouver…
D’autre part je ne suis pas sur de comprendre… L’adresse du LCD (ici 0×27) est un paramètre ‘physique’ du composant, je me trompe? si oui comment puis-je vérifier si l’adresse est effectivement correcte?
Merci a l’avance pour votre aide,
et bonne fête a vous aussi!

Leave a comment

All comments are moderated before being published

Recommended blog posts

  1. Install ESP32 now from the board manager
  2. Lüftersteuerung Raspberry Pi
  3. Arduino IDE - Programmieren für Einsteiger - Teil 1
  4. ESP32 - das Multitalent
  5. OTA - Over the Air - ESP programming via WLAN