Robert Fletcher
Published

HD44780U LCD with Arduino: 4-Bit Interface, Custom Character

Learn how to interface a classic Hitachi HD44780U-compatible 16×2 character LCD with an Arduino Uno using only six GPIO pins. This project c

IntermediateWork in progress22
HD44780U LCD with Arduino: 4-Bit Interface, Custom Character

Things used in this project

Hardware components

Arduino Uno Rev3
Microcontroller
×1
HD44780U
Character display
×1
10 kΩ potentiometer
LCD contrast adjustment
×1
Breadboard
Prototyping
×1
Male-to-male jumper wires
Connections
×12
USB cable for Arduino Uno
Programming and power
×1
5 V power source
LCD/Arduino supply
×1

Software apps and online services

Arduino IDE
Arduino IDE
Write and upload firmware
Arduino LiquidCrystal Library
Control the HD44780-compatible LCD
Serial Monitor
Debug and monitor Arduino output
Fritzing
Optional: create the wiring diagram

Hand tools and fabrication machines

Wire cutter
Wire stripper
Small screwdriver
Soldering iron (generic)
Soldering iron (generic)
Solder
Digital multimeter
Breadboard jumper wire tool

Story

Read more

Schematics

HD44780U schematics

Code

Schematics

C/C++
                    Arduino Uno
                +------------------+
                |                  |
        +5V ----| 5V           D12 |---------- RS
        GND ----| GND          D11 |---------- E
                |               D5 |---------- DB4
                |               D4 |---------- DB5
                |               D3 |---------- DB6
                |               D2 |---------- DB7
                +------------------+
                                     
                              HD44780U LCD
                         +--------------------+
             GND --------| 1  VSS             |
             +5V --------| 2  VDD             |
                         |                    |
 Pot wiper --------------| 3  VO              |
 Arduino D12 ------------| 4  RS              |
 GND --------------------| 5  R/W             |
 Arduino D11 ------------| 6  E               |
                         |                    |
 NC ---------------------| 7  DB0             |
 NC ---------------------| 8  DB1             |
 NC ---------------------| 9  DB2             |
 NC ---------------------| 10 DB3             |
 Arduino D5 -------------| 11 DB4             |
 Arduino D4 -------------| 12 DB5             |
 Arduino D3 -------------| 13 DB6             |
 Arduino D2 -------------| 14 DB7             |
                         |                    |
 +5V / module-specific --| 15 A               |
 GND / module-specific --| 16 K               |
                         +--------------------+

             10 kΩ Contrast Potentiometer

                  +5V
                   |
                [ POT ]
                   |
                   +---------- VO
                   |
                  GND

Code

C/C++
#include <LiquidCrystal.h>

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

// Custom character: small arrow
byte arrowChar[8] = {
  B00000,
  B00100,
  B00110,
  B11111,
  B00110,
  B00100,
  B00000,
  B00000
};

void setup() {
  Serial.begin(9600);

  // Initialize a 16x2 LCD
  lcd.begin(16, 2);

  // Create custom character in CGRAM
  lcd.createChar(0, arrowChar);

  lcd.clear();

  lcd.setCursor(0, 0);
  lcd.print("HD44780U LCD");

  lcd.setCursor(0, 1);
  lcd.print("4-BIT MODE");

  Serial.println("HD44780U LCD test started.");
}

void loop() {

  delay(2000);

  // Demonstrate cursor positioning
  lcd.clear();

  lcd.setCursor(0, 0);
  lcd.print("Arduino Uno");

  lcd.setCursor(0, 1);
  lcd.print("LCD Controller");

  delay(2000);

  // Demonstrate custom character
  lcd.clear();

  lcd.setCursor(0, 0);
  lcd.write(byte(0));
  lcd.print(" Custom Char");

  lcd.setCursor(0, 1);
  lcd.print("HD44780U");

  delay(2000);

  // Demonstrate scrolling
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("4-bit parallel");

  lcd.setCursor(0, 1);
  lcd.print("LCD interface");

  delay(1000);

  for (int i = 0; i < 6; i++) {
    lcd.scrollDisplayLeft();
    delay(300);
  }

  delay(1000);

  for (int i = 0; i < 6; i++) {
    lcd.scrollDisplayRight();
    delay(300);
  }
}

Credits

Robert Fletcher
21 projects • 1 follower
Senior semiconductor engineer at AVAQ Semiconductor. With extensive experience in electronic components, supply chain solutions & sourcing.

Comments