lamaPLC: LCD 1602/2004 with I²C communication

The HD44780 chip-based 1602/2004 LCD module is bright and high-contrast, thanks to its LCD technology, which features a blue-green background. This display is well-suited to your projects if you need a screen with a wide viewing angle, a compact design, and low power consumption. The LCD 1602 can display 16 characters in two rows, while the LCD 2004 can display 20 characters in four rows. Additionally, 1602/2004 displays can be easily connected using an I²C adapter.

LCD 1602LCD 1602LCD 2004LCD 2004
LCD 1602 Front Side
16 charachers
2 rows
LCD 1602 Back Side
16 charachers
2 rows
LCD 2004 Front Side
20 charachers
4 rows
LCD 2004 Back Side
20 charachers
4 rows

Features

  • Display Mode: STN, BLUB
  • Display Format: 16 Characters x 2 Lines
  • Viewing Direction: 6 O'clock
  • Input Data: 4-Bit or 8-Bit interface available
  • Display Font: 5 x 8 Dots
  • Power Supply: Single Power Supply (5V±10%)
  • Driving Scheme: 1/16 Duty, 1/5 Bias
  • Backlight (side): white LED

interfaces

Pinsymboldescriptionfunction
1VssGROUND0V (GND)
2VccPOWER SUPPLY FOR LOGIC CIRCUIT+5V
3VEELCD CONTRAST ADJUSTMENT
4RSINSTRUCTION/DATA REGISTER SELECTIONRS = 0 : INSTRUCTION REGISTER
RS = 1 : DATA REGISTER
5R/WREAD/WRITE SELECTIONR/W = 0 : REGISTER WRITE
R/W = 1 : REGISTER READ
6EENABLE SIGNAL
7DB0DATA INPUT/OUTPUT LINES8 BIT: DB0-DB7
8DB1DATA INPUT/OUTPUT LINES8 BIT: DB0-DB7
9DB2DATA INPUT/OUTPUT LINES8 BIT: DB0-DB7
10DB3DATA INPUT/OUTPUT LINES8 BIT: DB0-DB7
11DB4DATA INPUT/OUTPUT LINES8 BIT: DB0-DB7
12DB5DATA INPUT/OUTPUT LINES8 BIT: DB0-DB7
13DB6DATA INPUT/OUTPUT LINES8 BIT: DB0-DB7
14DB7DATA INPUT/OUTPUT LINES8 BIT: DB0-DB7
15LED+SUPPLY VOLTAGE FOR LED++5V
16LED-SUPPLY VOLTAGE FOR LED-0V

Font set

The LCD1602 employs the Hitachi HD44780 LCD controller chip. This chip features a built-in font and supports the definition of up to 8 custom characters.

There are two variants of the chip's ROM, each with different fonts: HD44780UA00, which contains Japanese katakana characters, and HD44780UA02, featuring Western European characters. LCD 1602 font set

I²C adapter

LCD 1602/2004 I²C adapter Reduction of the pin count for controlling an LCD from 12 to 2 pins: This practical module enables fast data transfer and converts the serial data output of an LCD into an I²C signal. It uses only four pins instead of 16 and supports six selectable I²C addresses, enabling simultaneous operation of up to 6 displays.

The I²C address for the 1602 and 2004 LCD modules depends on the specific I/O expander chip used on the I²C backpack (usually a PCF8574).

Common Default Addresses

  • 0x27: The most common default address for modules using the PCF8574T chip.
  • 0x3F: The common default address for modules using the PCF8574AT chip.

Address Ranges by Chip Type

The address is determined by the state of three hardware pins (A0, A1, A2) on the backpack.

  • PCF8574 / PCF8574T: Range is 0x20 to 0x27
  • PCF8574A / PCF8574AT: Range is 0x38 to 0x3F

How to Change the Address

Most I²C backpacks have three sets of solder pads labeled A0, A1, and A2.

  • Default State: Usually, these pads are “open” (high), resulting in the default address (0x27 or 0x3F).
  • Changing Address: Shorting (soldering) a pad connects that address bit to ground (low), changing the address.

Configuration Table (for PCF8574)

  • All Open: 0x27
  • A0 Shorted: 0x26
  • A1 Shorted: 0x25
  • A2 Shorted: 0x23
  • All Shorted: 0x20

Arduino example

Connect the 4 pins of the I²C backpack to your Arduino as follows:

  • GND to GND.
  • VCC to 5V.
  • SDA to A4 (on Uno/Nano) or the dedicated SDA pin.
  • SCL to A5 (on Uno/Nano) or the dedicated SCL pin.

Library Installation

Open the Arduino IDE, go to Sketch > Include Library > Manage Libraries, and search for and install “LiquidCrystal I2C” (by Frank de Brabander or Marco Schwartz).

This sketch works for both 1602 and 2004 displays. Ensure you update the 0x27 address and the 16, 2 dimensions if necessary:

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
 
// Set the LCD address to 0x27 for a 16 chars and 2 line display
// Change to (0x3F, 20, 4) for a 2004 display if 0x27 doesn't work
LiquidCrystal_I2C lcd(0x27, 16, 2); 
 
void setup() {
  lcd.init();          // Initialize the LCD
  lcd.backlight();     // Turn on the backlight
 
  lcd.setCursor(0, 0); // Move cursor to column 0, row 0
  lcd.print("Hello, Arduino!");
 
  lcd.setCursor(0, 1); // Move to second row
  lcd.print("I2C LCD Example");
}
 
void loop() {
  // Add dynamic content here if needed
}

display topics on lamaPLC