Arduino - LCD 20x4

In this Arduino LCD 20x4 I2C tutorial, we will learn how to connect an LCD 20x4 (Liquid Crystal Display) to the Arduino board via I2C Interface.

Hardware Required

1×Arduino UNO or Genuino UNO
1×USB 2.0 cable type A/B
1×LCD 20x4
1×Jumper Wires
1×(Optional) 9V Power Adapter for Arduino
1×(Recommended) Screw Terminal Block Shield for Arduino Uno
1×(Optional) Transparent Acrylic Enclosure For Arduino Uno

Or you can buy the following sensor kits:

1×DIYables Sensor Kit (30 sensors/displays)
1×DIYables Sensor Kit (18 sensors/displays)
Please note: These are Amazon affiliate links. If you buy the components through these links, We will get a commission at no extra cost to you. We appreciate it.

About LCD I2C 20x4


LCD 20x4 I2C uses I2C interface, so it has 4 pins:

  • GND pin: needs to be connected to GND (0V).
  • VCC pin: the power supply for the LCD, needs to be connected to VCC (5V).
  • SDA pin: I2C data signal
  • SCL pin: I2C clock signal
LCD 20x4 I2C Pinout

LCD Coordinate

LCD I2C 20x4 includes 20 columns and 4 rows. the conlums and rows are indexed from 0.

Arduino LCD I2C Coordinate

Wiring Diagram

Arduino LCD 20x4 I2C Wiring Diagram

This image is created using Fritzing. Click to enlarge image

LCD I2C Arduino Uno, Nano Arduino Mega
Vin 5V 5V
SDA A4 20
SCL A5 21

How To Program For LCD I2C

Thanks to the LiquidCrystal_I2C library, the using LCD is a piece of cake.

  • Include the library:
#include <LiquidCrystal_I2C.h> // Library for LCD
  • Declare a LiquidCrystal_I2C object with I2C address, the number of columns, the number of rows:
LiquidCrystal_I2C lcd(0x27, 20, 4); // I2C address 0x27, 20 column and 4 rows
  • Initialize the LCD.
lcd.init(); //initialize the lcd lcd.backlight(); //open the backlight
  • Move cursor to the desired position (column_index, row_index)
lcd.setCursor(column_index, row_index);
  • Print a message to the LCD.
lcd.print("Hello World!");


The I2C address of LCD can vary according to the manufacturers. In the code, we used 0x27 that is specified by DIYables manufacturer

Arduino Code

/* * Created by * * This example code is in the public domain * * Tutorial page: */ #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x27, 20, 4); // I2C address 0x27, 20 column and 4 rows void setup() { lcd.init(); // initialize the lcd lcd.backlight(); lcd.setCursor(0, 0); // move cursor the first row lcd.print("LCD 20x4"); // print message at the first row lcd.setCursor(0, 1); // move cursor to the second row lcd.print("I2C Address: 0x27"); // print message at the second row lcd.setCursor(0, 2); // move cursor to the third row lcd.print("DIYables"); // print message at the third row lcd.setCursor(0, 3); // move cursor to the fourth row lcd.print(""); // print message the fourth row } void loop() { }

Quick Steps

  • Navigate to the Libraries icon on the left bar of the Arduino IDE.
  • Search "LiquidCrystal I2C", then find the LiquidCrystal_I2C library by Frank de Brabander
  • Click Install button to install LiquidCrystal_I2C library.
Arduino LiquidCrystal I2C library
  • Copy the above code and open with Arduino IDE
  • Click Upload button on Arduino IDE to upload code to Arduino
  • See the result on LCD
Arduino display text on LCD
  • Try modifying text and position

LCD I2C Selection Guide

There are various types of LCD I2C displays available on the market, differing mainly in background color and the I2C address selection option.

LCD I2C 20x4 Selection Guide

For Color Options: Typically, there are two background colors available: green and blue.

For I2C address selection option:

  • With a jumper: This option allows switching between two I2C addresses, which is useful if you are using two LCDs simultaneously in the code. However, when your code uses only one LCD is used, it can cause confusion with I2C addresses. And it also takes up more space.
  • Without a jumper: This configuration has a fixed I2C address, making it very convenient when your project involves using only one LCD display. Since most applications use a single LCD, this type is highly recommended.

Video Tutorial

We are considering to make the video tutorials. If you think the video tutorials are essential, please subscribe to our YouTube channel to give us motivation for making the videos.

The Best Arduino Starter Kit