I2C LCD Interfacing with Arduino Nano

I2C LCD Advantages With Arduino

I2C Module reduces number of pins used to connecting LCD to 4, it relies on serial communication with your controller, apart from this you could also connect multiple I2C devices on same pins on your controller and then address them you may find on Serial monitor from your Arduino IDE.

I2C Module contains SDA this is the pin for Serial Data communication and other one is SCL which is used to provide for Serial clock input, rest of the two pins are for powering your LCD and I2C. 

You May Watch This Video to understand how I2C module works with LCD and Arduino.



Steps For Using I2C LCD, And For Connecting I2C With Arduino Nano

Step 1. connect your LCD with I2C Module and Arduino as shown in images below.





 Step 2. Set you Arduino IDE for Arduino nano as shown in image you are also required to download LiquidCrystal I2C library as shown in image.


Step 3. We will check for address assigned to our I2C LCD, using serial monitor using the following code as given under.

#include <Wire.h> //include Wire.h library
void setup()
{
  Wire.begin(); // Wire communication begin
  Serial.begin(9600); // The baudrate of Serial monitor is set in 9600
  while (!Serial); // Waiting for Serial Monitor
  Serial.println("\nI2C Scanner");
}
void loop()
{
  byte error, address; //variable for error and I2C 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("Unknown 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 the next I2C scan
}

You should be able to see following on your serial monitor here 0x27 is the address for your LCD. 


Step 4. Once we have found out the address now its is the time to upload code for writing LCD, given below is the code for LCD

#include <LiquidCrystal_I2C.h> //You might need to install this library in Arduino IDE 

LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C address 0x27, 16 column and 2 rows
void setup()
{
  lcd.init(); // initialize the lcd
  lcd.backlight();
  lcd.setCursor(3,0);
  lcd.print ("Tech School");
  lcd.setCursor(5,1);
  lcd.print("I2C LCD");
}

void loop()
{           
}

Step 5. Results after uploading sketch.


So we have successfully connected and programmed I2C LCD with Arduino Nano



Comments

Popular posts from this blog

DS3231 Real Time Clock Interfacing With Arduino

FM Transmitter Project

4 Way Traffic Signal Using Flip Flops