How to Interface 16×2 LCD With Arduino Uno

by Rachana Jain in Circuits > Arduino

103 Views, 0 Favorites, 0 Comments

How to Interface 16×2 LCD With Arduino Uno

Interfacing-16×2-LCD-with-Arduino.jpg

A 16x2 LCD (Liquid Crystal Display) is commonly used in electronics projects for displaying sensor readings, messages, or real-time data.

In this project, we will interface a 16x2 LCD module with an Arduino Uno and display a custom message

Supplies

  1. Arduino Uno
  2. 16x2 LCD Display
  3. Potentiometer (10KΩ) for contrast control
  4. Resistor (220Ω)
  5. Breadboard & Jumper Wires

What Is a 16×2 LCD Module?

A 16×2 LCD module is a widely used Liquid Crystal Display (LCD) that can show 16 characters per line on 2 lines, making it ideal for displaying text and simple symbols in embedded systems and microcontroller-based projects.

Key Features

  1. LCD displays up to 32 characters at a time.
  2. Most 16×2 LCDs use the Hitachi HD44780 driver, making them easy to interface with microcontrollers like Arduino, STM32, and Raspberry Pi.
  3. It operates in 4-bit or 8-bit modes, requiring 4 or 8 data lines for communication.
  4. Many LCDs include an LED backlight for visibility and a potentiometer to adjust contrast.
  5. Can be controlled using direct GPIO, I2C, or SPI with an adapter.

16×2 LCD Pinout Diagram

16x2 LCD pinout Diagram.jpg

Power and Control Pins:

  1. GND (Ground) – Connect this pin to the ground (0V) of the power supply.
  2. VCC (Power Supply) – Provides power to the LCD; typically connected to +5V.
  3. VO (Contrast Adjustment) – Controls the display contrast. A 10kΩ potentiometer is usually connected between VCC, GND, and VO to adjust the contrast level.
  4. RS (Register Select) – Used to differentiate command and data:
  5. RS = 0 → Command mode (for sending instructions like cursor position).
  6. RS = 1 → Data mode (for sending character data to be displayed).
  7. R/W (Read/Write) – Selects read or write operation:
  8. R/W = 0 → Write to LCD (default mode for most applications).
  9. R/W = 1 → Read from LCD (used to check busy status via D7 pin).
  10. E (Enable) – Latches data into the LCD when transitioning from HIGH to LOW. The signal must be held HIGH for at least 450ns before going LOW.

Data Pins (D0 to D7):

These 8 pins (D0–D7) are used to send data/commands to the LCD.

  1. In 8-bit mode: All 8 data pins (D0–D7) are used.
  2. In 4-bit mode: Only D4 to D7 are used, while D0 to D3 are grounded.

Backlight Pins:

LED (+) (Anode) – Connect to +5V through a 220Ω resistor to power the backlight.

LED (-) (Cathode) – Connect to GND to complete the backlight circuit.

Interfacing LCD With Arduino in 8-bit Mode

Interfacing LCD with Arduino in 8-bit mode.jpg

In this project, we will interface a 16×2 LCD module with an Arduino UNO in 8-bit mode. This means all 8 data lines (D0–D7) will be used for communication. Instead of checking the busy flag (D7 pin), we will introduce a small delay after each command execution. The R/W pin will be permanently grounded, as we will only write data to the LCD.

Code

Upload the following code to Arduino:

/*
Interfacing LCD with Arduino in 8-bit mode
by www.playwithcircuit.com
*/
#include <LiquidCrystal.h>
// We are using JHD 16x2 alphanumeric LCD using HD44780 controller for its controller
// initialize the library with the numbers of the interface pins
// Here We initlialize LCD in 4 bit mode when R/W pin (Pin 5 of LCD) is permanently attached to GND
// LCD side / Arduino Side Pin
// (Pin 4 )RS = 12
// (Pin 6 )E = 11
// (Pin 7 )D0 = 2
// (Pin 8 )D1 = 3
// (Pin 9 )D2 = 4
// (Pin 10)D3 = 5
// (Pin 11)D4 = 6
// (Pin 12)D5 = 7
// (Pin 13)D6 = 8
// (Pin 14)D7 = 9
// Pin No 1 and 16 of LCD of should be connected to GND
// Pin No 2 and 15 of LCD of should be connected to VCC
// A 10k pot should be connected b/w VCC and GND and its variable o/p pin shpuld be connected to VEE (pin 3 of LCD) to control contrast of LCD.
LiquidCrystal lcd(12, 11, 2,3,4,5,6,7,8,9);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
}
void loop() {
// set the cursor to (column = 0,row = 0)
lcd.setCursor(0, 0);
lcd.print("Hello World !");
// set the cursor to (column = 0,row = 1)
lcd.setCursor(0, 1);
lcd.print("playwithcircuit");
while(1);
}

The Output of Code


To learn how to interface LCD with Arduino in 4-bit mode checkout: https://playwithcircuit.com/interfacing-16x2-lcd-with-arduino/