Arduino

Arduino Tutorial #24 How to connect I2C with LCD.

How to connect I2C with LCD

in this tutorial we will learn how to connect I2C with LCD. It will reduce 4 input/output ports on Arduino board.  And wiring is much simpler and easier to connect. So let’s get started.

For this you will need

  1. Arduino,
  2. I2C,
  3. Breadboard (optional if you solder I2C with LCD),
  4. Jumper wires.
I2C
I2C

This is I2C serial interface adapter. We can adjust contrast of LCD by this potentiometer. We can solder this directly on LCD. But we have already solder the LCD so in this tutorial we are going to connect I2C and LCD by breadboard. Do connection as shown in diagram.

 

Circuit diagram for I2C with LCD
I2C with LCD circuit diagram
I2C with LCD circuit diagram

 

Download library for Liquid_Crystal_I2C. After downloading it, unzip it and change the name of folder to LiquidCrystal_I2C. And copy that folder and paste it to Arduino libraries.  Before uploading any sketch first we need to find out its I2C address. I2C scanner for finding address. Copy that code and paste it. Compile & Upload the sketch. Go to serial monitor. Now you can see its address. Copy that address.

And goto examples –> LiquidCrystal_I2C –>  hello world.

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

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

void setup()
{
 // initialize the LCD
 lcd.begin();

// Turn on the blacklight and print a message.
 lcd.backlight();
 lcd.print("Hello, world!");
}

void loop()
{
 // Do nothing here...
}

Change lcd address to previously copied address.

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

Compile and upload the sketch, now you can see hello world on the screen. If it is not showing anything on screen you can adjust contrast of lcd by adjusting potentiometer.

Now goto examples –> LiquidCrystal –> display

#include <Wire.h>

#include <LiquidCrystal_I2C.h>

// Set the LCD address to 0x27 for a 16 chars and 2 line display

LiquidCrystal_I2C lcd(0x27, 16, 2);

Copy this code and instead of

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

this code paste this I2C library to this sketch and delete 16X2 in lcd.begin.  Compile and upload the sketch now you can see it is turn on & off display in each 500 millisecond.

 

LIST OF COMPONENT BUY ONLINE:

http://amzn.to/2fvSRJq   (Arduino)

http://amzn.to/2zg8aeX (I2C)

http://amzn.to/2yBk7eT (LCD display)

http://amzn.to/2wxPmWz  (Breadboard)

http://amzn.to/2vJ3lvo   (Jumper wire)

TILL THEN KEEP LEARNING KEEP MAKING 🙂

 

2 thoughts on “Arduino Tutorial #24 How to connect I2C with LCD.

Leave a Reply

Your email address will not be published. Required fields are marked *