How to set up and use a 1602 I2C serial LCD with your ARDUINO.

This tutorial will show you How to set up and use a 1602 I2C serial LCD with your ARDUINO. , In this tutorial I will be using a ARDUINO UNO but the connections will be similar for all ARDUINO boards.

  The video below shows the LCD in action!

 

 

 

 

 

 

i2clcd

How to set up and use a 1602 I2C serial LCD with your ARDUINO.

Connecting the I2C lcd to your ARDUINO is simple.  First  connect the VCC & ground from the LCD’s I2C pins to the power and ground pins of your ARDUINO board, Next connect the SCL pin to pin A5 on your ARDUINO board and the SDA pin of your I2C LCD to pin A4 on your ARDUINO board.

 

Parts List.

  1. ARDUINO board
  2. Potentiometer
  3. 1602 I2C 16 X 2 LCD screen
  4. Bread board
  5. jumper wires

For the demonstration of how to use the I2C LCD we are going to connect a potentiometer to the ARDUINO and display the value on the LCD display, Connect the middle pin of the pot to analog pin A0 on your ARDUINO and the other two pins to ground and power..

If you know the address of your 1602 serial I2C LCD you can skip the next step!!

 

Detecting your I2C address.

If you don’t know the LCD’s I2C address just copy and past the following code into your ARDUINO IDE & upload it to your board, Open your serial monitor and write down the address that is displayed on the monitor.  This code and more info about it can be found at: http://playground.arduino.cc/Main/I2cScanner

 

#include <Wire.h>

 

void setup()

 

{

 

  Wire.begin();

 

  Serial.begin(9600);

 

  Serial.println(\nI2C Scanner”);

 

}

 

void loop()

 

{

 

  byte error, address;

 

  int nDevices;

 

  Serial.println(“Scanning…”);

 

  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.

 

    Wire.beginTransmission(address);

 

    error = Wire.endTransmission();

 

    if (error == 0)

 

    {

 

      Serial.print(“I2C device found at address 0x”);

 

      if (address<16)

 

        Serial.print(“0”);

 

      Serial.print(address,HEX);

 

      Serial.println(”  !”);

 

      nDevices++;

 

    }

 

    else if (error==4)

 

    {

 

      Serial.print(“Unknow error at address 0x”);

 

      if (address<16)

 

        Serial.print(“0”);

 

      Serial.println(address,HEX);

 

    }

 

  }

 

  if (nDevices == 0)

 

    Serial.println(“No I2C devices found\n);

 

  else

 

    Serial.println(“done\n);

 

  delay(5000);           // wait 5 seconds for next scan

 

}

  Time to play with the LCD!!

You will need to download and install the following library for your I2C serial LCD to work :  https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads… Download the 1.3.4 version!

  Now that you have your I2C address you can copy and past the following code into your IDE to have some fun with your LCD screen. First look at the picture before the code and change the value that is circled in the code to your I2C address, Then upload it to your ARDUINO.
  Once the code is uploaded to your arduino just turn the potentiometer and the value will be displayed on your LCD screen.
lcd_pot Arduino 1.6

How to set up and use a 1602 I2C serial LCD with your ARDUINO.

 

 

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Set the LCD I2C address
LiquidCrystal_I2C lcd(0x3f, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
void setup()
{
lcd.begin(16, 2);  // initialize the lcd
lcd.clear();

}
void loop()
{
int val = (analogRead(A0)); //read analog pin A0
lcd.setCursor(5, 0);
lcd.print(“VALUE=”);
lcd.setCursor(6, 1);
lcd.print(val);
delay(500);
lcd.clear();
}

If you have any questions or comments please post them on our Facebook page.

Also if your looking for some more ARDUINO projects or info check out our projects page.

 

 

 

How to set up and use a 1602 I2C serial LCD with your ARDUINO.