During the building of your projects for Arduino, you’ll often need to read the output data directly from a LCD display. In this lesson we will show how to mount a LCD display on your Arduino using the I2C communication. Finally you will see how to program it with a simple example showing how to display text on the display.



  • Osoyoo UNO Board (Fully compatible with Arduino UNO rev.3) x 1
  • I2C LCD 1602 Display x 1
  • F/M jumpers
  • USB Cable x 1
  • PC x 1


About I2C LCD 1602 Display

The integration of an LCD display greatly facilitates the interactivity of the project you are developing, allowing the user to directly read some output parameters. These values can be either a simple text or numerical values read by the sensors, such as temperature or pressure, or even the number of cycles that the Arduino is performing.

However, these displays have a small problem. When they are connected to a microcontroller (such as Arduino for example), these displays require virtually many connection PINs occupying practically almost all available IO and leaving the multiprocessor few outputs for any other devices and sensors. This problem has been solved thanks to the communication on the I2C bus.

The LCD1602 display has an integrated microchip that manages this type of communication, and then all of the input and output information are limited to only two PINs (excluding power supply). I2C is a type of serial bus developed by Philips, which uses two bidirectional lines, called SDA (Serial Data Line) and SCL (Serial Clock Line). Both must be connected via pulled-up resistors. The usage voltages are standard as 5V and 3.3V.

The blue potentiometer on the I2C LCD1602 (see the figure below) is used to adjust the backlight  for better display.And there is a jumper on the board, if you take away this jumper , the backlight will aways be off.

For the usagage of other functions, pleae refer to the “LiquidCrystal_I2C.h” in the sourcecode of I2C LCD library.


Before you write the code you have to build the circuit. To do this, connect the pins as follows:

Osoyoo UNO LCD1602


  • For Mega2560: the I2C connections are on SDA=20 and SCL=21. So go ahead and wire these up, along with the two power leads to the 5V and GND terminals.
  • For Arduino Leonardo: connect SDA to digital pin 2 and SCL to digital pin 3 on your Arduino.

From sketches of Fritzing, you can look at the connections to be done in a simpler way:

Find the I2C address

Each device has an I2C address that it uses to accept commands or send messages. For Uno board, this address usually is 0x27. But sometimes the address might be changed 0x37,0x24 …., So let’s go and look for the one on your device.

Download ic2_scanner sketch zip file , then unzip and load it into Arduino IDE. By opening up the serial monitor in the upright corner, Arduino will scan the address range looking for a reply. Most Arduino board will show 0x27, however it be other number.

Write down the Address that you have found, you’ll need it in the next step.

Upload Sketch

After above operations are completed, connect the Arduino board to your computer using the USB cable. The green power LED (labelled PWR) should go on.

Install Library

To use the I2C protocol with an LCD display and Arduino, there is a special library to be downloaded and included in the code. The name of this library is Liquid Crystal I2C. Download the library, a zip file (you can download it from here) and extract the contents in the libraries folder of the Arduino IDE. You can do directly from the Arduino IDE, select  Sketchinclude Library > Add .ZIP library from the menu.

Library Support Functions

  • LiquidCrystal_I2C() //set the LCD address for a 16 chars and 2 line display
  • init() //Initialization for the LCD
  • clear() //clear display, set cursor position to zero
  • home() //set cursor position to zero
  • createChar() //Fill the first 8 CGRAM locations with custom characters
  • setCursor() //set the position of the cursor
  • cursor() //Turns the underline cursor on
  • noCursor() //Turns the underline cursor off
  • blink() //Turn on the blinking cursor
  • noBlink() //Turn off the blinking cursor
  • display() //Turn the display on(quickly)
  • noDisplay() //Turn the display 0ff(quickly)
  • backlight() //Turn the backlight on
  • noBacklight() //Turn the backlight off
  • scrollDisplayLeft() //Make the display scroll left without changing the RAM
  • scrollDisplayRight() //Make the display scroll right without changing the RAM
  • autoscroll() //This will ‘right justify’ text from the cursor
  • noAutoscroll() //This will ‘left justify’ text from the cursor
  • leftToRight() //This is for text that flows Left to Right
  • rightToLeft() //This is for text that flows Right to Left

Code Program

You can download the sketch from this link or copy below code to your Arduino IDE window:

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 for a 16 chars and 2 line display
void setup()
 lcd.init();                      // initialize the lcd 
 // Print a message to the LCD.
 lcd.print("Hello, world!");
void loop()

Compile and upload

Open the Arduino IDE and select corresponding board type and port type for your Arduino board.

After compile this sketch, simply click the “Upload” button in the environment. Wait a few seconds – you should see the RX and TX leds on the board flashing. If the upload is successful, the message “Done uploading.” will appear in the status bar.

Running Result

A few seconds after the upload finishes, you should now see your I2C LCD1602 display the static characters: “Hello, World!”.

Extended experiment

In this experiment, the sketch will make a connection between Arduino and I2C LCD display and then print a text on two lines. The first line will display “Hello all !” and second the “Welcome to !” message.The circuit and the board / port type settings are same as above example.

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

char array1[]=" Hello all !                "; //the string to print on the LCD
char array2[]="Welcome to      "; //the string to print on the LCD
int tim = 500; //the value of delay time
// initialize the library with the numbers of the interface pins
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display

void setup()
  lcd.init(); //initialize the lcd
  lcd.backlight(); //open the backlight 

void loop() 
  lcd.setCursor(15,0); // set the cursor to column 15, line 0
  for (int positionCounter1 = 0; positionCounter1 < 26; positionCounter1++)
    lcd.scrollDisplayLeft(); //Scrolls the contents of the display one space to the left.
    lcd.print(array1[positionCounter1]); // Print a message to the LCD.
    delay(tim); //wait for 250 microseconds
  lcd.clear(); //Clears the LCD screen and positions the cursor in the upper-left  corner.
  lcd.setCursor(15,1); // set the cursor to column 15, line 1
  for (int positionCounter = 0; positionCounter < 26; positionCounter++)
    lcd.scrollDisplayLeft(); //Scrolls the contents of the display one space to the left.
    lcd.print(array2[positionCounter]); // Print a message to the LCD.
    delay(tim); //wait for 250 microseconds
  lcd.clear(); //Clears the LCD screen and positions the cursor in the upper-left corner.

Compile and upload this sketch to the Osoyoo UNO board, you should now see your I2C LCD1602 display the flowing characters: “Hello all !” and “Welcome to”.

Leave a Reply

WordPress spam blocked by CleanTalk.
Bombax Theme designed by itx