How to connect Arduino UNO to I2c LCD display with Sample Code

posted in: arduino, IOT, uno | 0
Arduino UNO connected to lcd via 12c back pack

I know this is a subject that’s been done to death but having been asked to give it the Blind Guy Tech “take” I thought eh, why not? So here is my version of how to connect the Arduino UNO I2c LDC Display. But, full disclosure, a simple Google search will turn up many very capable tutorials on this subject.

Some things you will need.

Arduino UNO R3 from AliExpress

LCD module I2C from AliExpress

Dupont jumper wire Arduino from AliExpress

Wiring up is kind of simple…

I2C Board of LCD Arduino

GND <—> GND

VCC <—> 5V

SDA <—> A4

SCL <—> A5

And below is some sample code for the Arduino IDE. You will need to make sure the Library for the LiquidCrystal LCD display is installed. If you don’t have it installed follow the link below for download and instructions.

Library for the LiquidCrystal LCD display

// **********************************************************************
//
// I2c LCD Arduino demo 
// by Al McDivitt 
//   iotXplain     www.iotxplain.com.au
//
//***********************************************************************
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// might need to be  0x27 or at 0x3f.
#define I2C_ADDR     0x27 // <--Change to match your display

LiquidCrystal_I2C lcd(I2C_ADDR,2,1,0,4,5,6,7,3,POSITIVE);// may need to be changed

int n = 0;

void setup ( )
{
  lcd.begin ( 16, 2 ); // adjust for whatever display you use.
  lcd.setBacklight(1);
  lcd.print("iotXplain - Hi!");
 
}

void loop ()
{
  lcd.setCursor (0,1);
  lcd.print(n++,HEX);
   lcd.print("H");
  delay(1000);
}

Upload this code to your Uno. It should run and you will be presented with the LCD saying hi and counting in Hex. Wow!!! 

iot arduino UNO LCD I2c  Display c++ code programing
The complete Setup Arduino UNO and I2c LCD
iot arduino UNO LCD I2c  Display c++ code programing
The connections to the I2c LCD backpack
iot arduino UNO LCD I2c  Display c++ code programing
Connections to the Arduino UNO board

A few notes: 

I2C  is a communication method developed by Philips to allow “Inter-Integrated Circuit” communication on a two-wire bus. 

There are different ways to connect an LCD to the chip on the backpack and there is no particular standard.

You may want to try  different initialization parameters:

  • LiquidCrystal_I2C lcd(I2C_ADDR,2,1,0,4,5,6,7,3,POSITIVE);
  • LiquidCrystal_I2C lcd(I2C_ADDR,4,5,6,0,1,2,3,7,NEGATIVE);
  • LiquidCrystal_I2C lcd(I2C_ADDR,6,5,4,0,1,2,3,7,NEGATIVE);

In some cases, the backpack must be installed on the LCD.

  • Mount the backpack and make sure it is insulated from the LCD board.
  • Solder the backpack to the LCD,

Well, that brings us to the end of this little tour of things relating to I2c LCD’s on Arduino ONU boards. Hope you got something out of it.

So, you can see whether you wish to show temperature from a DHT22 device, time via a RTC module. or just like seeing your name in lights, using an I2C LCD display with UNO is both simple and economical.

Cheer’s Al

Note There’s been a price reduction for my Getting started with Espruino using ESP8266 & Windows10 ebook. Check it out.

VigLink badge

Leave a Reply

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