Arduino and LCD display

HD44780 controller

1. display

The LCD display with HD44780driver is one of the most popular devices of this type. Its main advantages are: low price, high availability and easy operation. The layout can be found in several weddings. They differ from each other: backlight colours and characters and dimensions, i.e. the maximum number of characters displayed at one time.

There are displays available in our shop:

16x2 - 16 columns and 2 rows (32 characters)

8x2 - 8 columns and 2 rows (16 characters)

20x4 - 20 columns and 4 rows (80 characters)

2. HD44780 - control

Most often the displays have sixteen outputs. Power supply (VDD, VSS), contrast control pin (V0), three control lines (RS, R/W, ENABLE), eight data bus lines (D0...D7) and separate backlight supply (LEDA+ , LEDK-).

The drawing shows the dimensions and outputs of the 16x2 LCD display.

No. Name Description
1 VSS Mass
2 VDD Power supply (+5V)
3 V0 Contrast
4 RS

Selection of display instruction register (low state) or data register (high state)

5 R/W Reading (low state) / Recording (high state). In the mode without reading the occupancy flag, the output can be connected to ground.
6 E If a falling slope occurs, the display is ready to read data from the bus.
7 DB0

The data bus. These lines are followed by data and instructions for the display.

8 DB1
9 DB2
10 DB3
11 DB4
12 DB5
13 DB6
14 DB7
15 LEDA Backlight power supply.
16 LEDK Mass of the backlight

Four data lines will be used to operate the display: D4 D5, D6, D7 and the outputs: E, RS. R/W will be connected to ground. For more information about the control modes, see the description of the display.

Thanks to the library LiquidCrystal The operation of the display from Arduino comes down to the following steps:

  • Initialization - the LiquidCrystal method (rs, rw, enable, d4, d5, d6, d7) is used for this purpose. For example:
    LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2); 
    //pin RS - podłączony do cyfrowego wyjścia 12, R/W-11 itd.)
    lcd.begin(16, 2); // ustawienie typu wyświetlacza, w tym wypadku 16x2
    
  • Data to be displayed:
    lcd.setCursor (columnal, row); - giving the place from which the display of characters will start. E.g.
    lcd.setCursor(0, 1) 
    // kolumna nr 0, wiersz nr 1 (numerowanie rozpoczyna się od zera)
    

    lcd.print(data)- provide a string to be displayed in "data" tags. E.g. cd.print("hello, world!"); - thedisplay will show the following text hello, world!

Wider description of the library and sample programs can be found in Arduino project documentation.

3. example

A program from the Arduino library's documentation entitled "The program". Hello World

Description:

Example of a program to operate a 16x2 LCD display in 4-bit mode without reading the occupancy flag



Connection:

LCD RS pin connected to digital output 12

LCD Enable pin connected to the digital output 11

LCD D4 pin connected to digital output no. 5
LCD D5 connected to digital output no. 4
LCD D6 connected to digital output no. 3
LCD D7 connected to digital output no. 2

LCD R/W pin connected to ground

VO (contrast) connected to the potentiometer. The potentiometer can be replaced by a voltage divider. In some cases a resistor with a value of several hundred ohms connected from the V0 output to ground will also be effective.

LCD LED+ backlight power (5V)

LCD LED - light weight

Although some displays have a built-in resistor to limit the supply current to the backlighting diodes, it is worth using an external limiter. In this case, the 5V line is connected via a 200 ohm resistor.

The figure shows the connection between the display and Arduino Uno module.

Code:
//Inicjalizacja połączeń
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() { 
// Wybór rodzaju wyświetlacza  - 16x2
lcd.begin(16, 2); 
//Przesłanie do wyświetlania łańcucha znaków hello, world!
lcd.print("hello, world!");
}
 
void loop(){ 
//Przejście kursora do pierwszej kolumny drugiego wiersza
lcd.setCursor(0, 1);?
//Odczyt oraz wyświetlenie czasu jaki upłynął od ostatniego resetu w sekundach
lcd.print(millis()/1000);
}

The same applies to devices with fewer and more characters displayed.

4 Summary

The display is an important tool in the process of communication between an electronic device and a person. It is useful for detecting errors during testing or viewing data collected by the microcontroller. Together with the buttons it forms the basis of the user interface.

Alphanumeric modules based on the HD44780 controller are extremely easy to use. When there is no need to display graphics, these devices perform very well and are eagerly used by hobbyists and professionals.

The drawing shows the connection of a 16x2 LCD display with a contact plate and connection wires.

Botland.store - shop for makers!