Use 16x2 LCD With I2C




About: My team has developed a new product. PLEASE CHECK IT OUT ON INDIEGOGO AND SHOW YOUR SUPPORT. CAMPAIGN LINK: I'm a tech and food enthusiast and also a Soccer Player. I lo...

In one of my previous Instructable, I showed you how to connect and interface an LCD to Arduino Uno and display values on it. But as observed, there were a lot of connections and if the project started getting a lot messy due to too many wires.

In this Instructable, I'll show you how to connect an LCD to an I2C, which will have only 4 pins to control and use the LCD. So let's get started.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Components Required

For this project you will need :

  • Arduino Uno
  • 16x2 LCD
  • I2C for 16x2 LCD
  • Hook-Up wires

With all these, let's get into the connections part.

Step 2: Connections

Refer the pictures and make the connections. It's quite simple, you just have to plug in the I2C in the ports of the LCD and solder it into place. Then connect the SCL pin to A4 pin on the Arduino and the SDA pin to the A5 pin on the Arduino.

I'm not soldering the I2C as I have already soldered header pins on the LCD. But I would suggest soldering the I2C on the LCD.

Step 3: Code

There is an LCD I2C master library included in the Arduino IDE. But there's a slight problem with the code in it. All the examples in this library assumes the default address of the I2C as 0x27. So first we have to find out what the address of our I2C is. We can do this by using the I2C scanner code. Once we have the I2C address we can replace this value in the example code and start using it.

I2C Scanner Code:

#include <Wire.h> 
void setup()
  while (!Serial);             //  wait for serial monitor
  Serial.println("\nI2C Scanner");
void loop()
  byte error, address;
  int nDevices;
  nDevices = 0;
  for(address = 1; address < 127; address++ )
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    error = Wire.endTransmission();
    if (error == 0)
      Serial.print("I2C device found at address 0x");
      if (address<16)
      Serial.println("  !");
    else if (error==4)
      Serial.print("Unknown error at address 0x");
      if (address<16)
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  delay(5000);           // wait 5 seconds for next scan

Example Code(To display characters entered in Serial Monitor):

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

LiquidCrystal_I2C lcd(0x3F,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display

void setup() { lcd.init(); // initialize the lcd lcd.backlight(); Serial.begin(9600); }

void loop() { // when characters arrive over the serial port... if (Serial.available()) { // wait a bit for the entire message to arrive delay(100); // clear the screen lcd.clear(); // read all the available characters while (Serial.available() > 0) { // display each character to the LCD lcd.write(; } } }

Step 4: The Output

Once you have uploaded the code, you are ready to go. For this Instructable I have taken the example of the Serial Print Code. So now after uploading the code, open the Serial Monitor and type a word and click "send". Now you should see this value getting displayed on the LCD.

That's All Folks !! Stay Tuned For More !!

Makerspace Contest 2017

Participated in the
Makerspace Contest 2017

Be the First to Share


    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    7 Discussions


    Question 6 months ago

    so i got it working but can only display text on the first line so how would you get text to second line on the lcd


    6 months ago

    Stuck on Scanning...


    7 months ago

    sketch_mar19a:8:7: error: expected unqualified-id before 'int'; // initialize the lcd


    7 months ago

    Yep A4 and A5 swapped. The scanner finds my address, but the other doesn't print a thing. Found the sketch was for a 20 x 4 at a different address...Unexpected when the demo here is 16 x 2. Corrected that and played with the contrast, and it runs now.


    7 months ago

    Can you tell me the source for the LiquidCrystal_I2C.h you are using? The one I've found with the Arduino IDE "Manage Libraries" tool says it may not work with current sketches and using your sketch above all my LCD does is blink off and back on once and does not display anything from the serial monitor input. Nor will it display anything if I clear the entire loop() and just enter a fixed write statement in the setup(). Thanks


    Question 8 months ago on Step 4

    I did the same connections as you did. the lcd power is on but its not showing anything.

    Actually, for checking the i2c address also, the serial monitor is not showing anything, at least it has to show no of connections also, but i cant see anything.

    The lcd is getting on but not displaying anything on the lcd screen. please help me

    I'm using Olimexino-32u4 arduino board


    8 months ago on Step 1

    Maybe there is a mistypo. Connection is worked with SDA to A4 and SDC to A5.