Arduino LCD 16x2 Display with I2C device

Submitted by CAAadmin on Thu, 08/11/2016 - 09:42
arduino lcd display with i2c

This program explains how to connect I2C with LCD - Connect SCL of I2C to A5 of arduino and SDA to A4 Pin number 1 of LCD should be near to GND,VCC,SCL, SDA line of I2C (to avoid confusion)

This Programs uses Wire.h (Comes with Arduino IDE) and LiquidCrystal_I2C.h

Get the LCD I2C Library here:

Move any other LCD libraries to another folder or delete them

The program for finding the I2C address is available here -- link will be added--

Full Arduino Program

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

// set the LCD address to 0x27 for a 16 chars 2 line display
// A FEW use address 0x3F
// Set the pins on the I2C chip used for LCD connections:
//                    addr, en,rw,rs,d4,d5,d6,d7,bl,blpol

LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

void setup()   
  Serial.begin(9600);  // Used to type in characters
  lcd.begin(16,2);   // initialize the lcd for 16 chars 2 lines, turn on backlight
// ------- Quick 3 blinks of backlight  -------------
  for(int i = 0; i< 3; i++)
  lcd.backlight(); // finish with backlight on  
//-------- Write characters on the display ------------------
// NOTE: Cursor Position: (CHAR, LINE) start at 0  
  lcd.setCursor(0,0); //Start at character 4 on line 0
  lcd.print("Hello, world!");
// Wait and then tell user they can start the Serial Monitor and type in characters to
// Display. (Set Serial Monitor option to "No Line Ending")
  lcd.setCursor(0,0); //Start at character 0 on line 0
  lcd.print("Use Serial Mon");
  lcd.print("Type to display");  

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