Skip to content

Interfacing 16x2 LCD display with Arduino Nano

16x2 lcd

Table of Contents

Abstract

In this article, you’ll learn a detailed, step-by-step method to interface a 16×2 LCD character display with the Arduino Nano using the Arduino IDE. By the end, you’ll be able to display text on the LCD — a fundamental building block for many microcontroller projects like menus, status readouts, timers, and sensors display.

🧭 Pre-Request

  • OS : Windows / Linux / Mac / Chrome
  • Arduino IDE

Hardware Required

🛠️
Get the right hardware kit
Arduino boards, sensors, and maker essential Kits—perfectly matched for your learning.
Explore Hardware →
  • Arduino Nano.
  • 16x2 LCD display.
  • Resistors.
  • Potentiometer (10 kΩ)
  • BreadBoard.
  • Mini USB Cable.
  • Connecting wires.
  • 5V DC power supply (Optional)
Components Purchase Link
Arduino Nano link
16x2 LCD link
Mini USB Cable link
Potentiometer (POT) link
BreadBoard large : small
Connecting Wires link
5V DC Adaptor link

Don't own a hardware 😢

No worries,

💡Still you can learn using simulation. check out simulation part 😃.

💡Power your mission with reliable Arduino Kits. Explore Hardware →

  • Arduino Nano

  • Arduino Nano

Connection Table

16x2 LCD can be connected in 4 wire and 8 wire mode. In this article 4 wire mode is demonstrated, as 8 wire mode is rarely used now a days.

Info

With I2C LCD interface, we can interface 16x2 LCD display in 2 wire mode. click here to know how to interface 16x2 LCD display in serial mode using 2 wire system.

LCD Pin LCD Function Arduino Nano Pin Notes
Pin 1 VSS (GND) GND Ground
Pin 2 VDD (+5 V) +5 V Power
Pin 3 V0 (Contrast) Pot middle pin Adjust contrast
Pin 4 RS (Register Select) D6 Defined above
Pin 5 RW (Read/Write) GND Always write
Pin 6 Enable (E) D5 Defined above
Pin 11 D4 D4 Defined above
Pin 12 D5 D3 Defined above
Pin 13 D6 D2 Defined above
Pin 14 D7 D1 Defined above
Pin 15 LED + (Backlight) +5 V via 220 Ω Backlight (optional resistor)
Pin 16 LED – (Backlight) GND Backlight

Note

💡 Potentiometer between LCD V0 and GND/VDD lets you adjust contrast so text is visible

Circuit Diagram

fig-Connection Diagram

📂 Code

#include <LiquidCrystal.h>

//  Pin Definitions
# define RS 6
# define E 5
# define D7 1
# define D6 2
# define D5 3
# define D4 4


// Initialize the LCD with the pins:
// LiquidCrystal(rs, en, d4, d5, d6, d7)
LiquidCrystal lcd(RS, E, D4, D5, D6, D7);

void setup() {
    lcd.begin(16, 2);  // Set the LCD size to 16 columns and 2 rows
    lcd.print("Welcome to"); // Print first line
    lcd.setCursor(0, 1);  // Move cursor to second line
    lcd.print("Aavishkarah"); // Print Second line
    delay(3000); // Delay of 3 sec
}

void loop() {
    // Print 0 to 9 with a delay of 1.5 sec for an infinite loop    
    for (int i=0; i<10; i++){
        lcd.clear();
        lcd.print(i);
        delay(1500);
    }
}

Code Explanation

Let’s break down the Arduino sketch line by line to clearly understand how the 16×2 LCD works with the Arduino Nano.

👉 Imports

#include <LiquidCrystal.h>
  • This line includes the LiquidCrystal library.
  • It provides ready-to-use functions to control 16×2 LCD displays such as print(), clear(), setCursor() etc.,

👉 Define LCD Pin Connections

3
4
5
6
7
8
9
//  Pin Definitions
# define RS 6
# define E 5
# define D7 1
# define D6 2
# define D5 3
# define D4 4
  • These #define statements assign Arduino Nano pins to the LCD control and data pins.
  • RS (Register Select) chooses between command mode and data mode.
  • E (Enable) triggers data transfer.
  • D4–D7 are data lines used in 4-bit mode, reducing the number of pins required.

👉 Create the LCD Object

// Initialize the LCD with the pins:
// LiquidCrystal(rs, en, d4, d5, d6, d7)
LiquidCrystal lcd(RS, E, D4, D5, D6, D7);
  • This creates an LCD object named lcd.
  • The pin order must be: RS, Enable, D4, D5, D6, D7
  • From this point onward, all LCD operations are performed using the lcd object.

👉 Initialize the LCD in setup()

  lcd.begin(16, 2);
  • lcd.begin(16, 2) initializes the LCD with 16 columns and 2 rows.
  • This must be called before sending any data to the LCD.

👉 Display Static Text

  lcd.print("Welcome to");
  lcd.setCursor(0, 1);
  lcd.print("Aavishkarah");
  delay(3000);
  • lcd.print("Welcome to") prints text on the first line.
  • lcd.setCursor(0, 1) moves the cursor to column 0, row 1 (second line).
  • lcd.print("Aavishkarah") displays text on the second line.
  • delay(3000) pauses execution for 3 seconds.
  • This allows the welcome message to stay visible before moving to the loop section.

👉 Display Numbers 0 to 9 Repeatedly

  for (int i=0; i<10; i++){
    lcd.clear();
    lcd.print(i);
    delay(1500);
  }
  • The loop() function runs continuously after setup() completes.
  • The for loop counts from 0 to 9.
  • lcd.clear() clears the LCD before printing the next number.
  • lcd.print(i) displays the current number.
  • delay(1500) holds each number on the display for 1.5 seconds.
  • After reaching 9, the loop restarts, creating an infinite display cycle.

Try It

  • Alter the output content on the display by passing your data argument to the lcd.print() method.

Simulation

Not able to view the simulation

  • Desktop or Laptop : Reload this page ( Ctrl+R )
  • Mobile : Use Landscape Mode and reload the page
🛠️
Get the right hardware kit
Arduino boards, sensors, and maker essential Kits—perfectly matched for your learning.
Explore Hardware →
  • Arduino Nano

  • Arduino Nano


Extras

Components details

Modules / Libraries Used

  • LiquidCrystal.h
    • It provides ready-to-use functions to control 16×2 LCD displays such as print(), clear(), setCursor() etc.,
    • More info
    • Github Source Code