Arduino I2C LCD


In this tutorial, you will learn how to wire up and use an alphanumeric LCD display on the Arduino platform. Unlike the normal LCD which uses up to 11 digital pins, the I2C LCD uses only 2 pin reserving the rest of the pins for other use. When you have finished reading this tutorial, you will be familiar with:

  • Wiring up the I2C LCD to the Arduino platform
  • Getting the Addresses of the Devices connected to the I2C bus
  • Displaying Data on the LCD

What You Will Need

We will need the following parts and libraries in this tutorial:

We will be using Eclipse for Arduino, if you haven’t setup please refer to my previous tutorial on eclipse for Arduino.
LiquidCrystal-I2C Library will be used in this tutorial. Please use this tutorial on how to add an Arduino library in eclipse

Setting up

At this point I assume you have secured all the prerequisites above and I will go straight to the point, the reason why you are here.

Connecting the LCD

The I2C Display uses only two wires i.e. SDA and SCL and the power supply. The Table below shows how to connect this display to Arduino Mega, Uno, and Nano

I2C Display Arduino Uno Arduino Mega Arduino Nano
SCL A5 21 A5
SDA A4 20 A4

Creating the project

Create a new project and name it I2CLCD_example1. If you don’t know how to create one please follow our tutorial here. Add the following libraries to your project

  • Wire
  • LiquidCrystal_I2C (from DFRobots)

Writing the program

After adding the libraries we are going to reference them as below.

Then create an object of the LiquidCrystal_I2C as below

This object takes three parameters the first one being the I2C address of the LCD, the second parameter is the number of columns of the display and the last one, the number of row i.e. since we are using a 16×2 this means this display has 16 columns and 2 rows.
Please note that the I2C Address of the LCD depends on the I2C module behind the display that’s being used. If your program does display anything, you may need to use an I2C scanner program to determine the address of your display.

Sample #1 – Display words on the screen

Create a project and name it I2CLCD_Example1. Copy and paste the following code
Connect your Arduino and upload the sketch

Sample #2 scrolling a word

Create a project and name it I2CLCD_Example2. Copy and paste the following code
Connect your Arduino and upload the sketch

The output will be as seen in the video below: