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.
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.
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.
Comments
Post a Comment