Arduino – LCD I2C - Tinkercad Simulation
Arduino – LCD I2C 16x2 display - Tinkercad Simulation
LCD displays with I2C LCD adapter are 16×2 and 20×4 character LCD displays.
This I2C LCD display contains 4 pins: Ground, VCC, SDA, and SCL.
Arduino Code at Tinkercad: https://www.tinkercad.com/things/68gKMm2VFm6
Circuit
First, check the address of the I2C LCD with the following code:
#include <Wire.h>
void setup() {
Serial.begin(9600);
Serial.println("\nI2C Scanner");
Serial.println("Scanning...");
byte device_count = 0;
Wire.begin();
for (byte address = 1;
address < 127; address++ ){
Wire.beginTransmission(address);
if (Wire.endTransmission() == 0) {
// Serial.print ("Found address: ");
Serial.print("I2C device found at address 0x");
Serial.print(address, HEX);
Serial.println(" !");
device_count++;
delay(1);
}
}
Serial.println ("Done.");
Serial.print ("Found ");
Serial.print (device_count);
Serial.println (" device(s).");
}
void loop() {}
Note the address of I2C LCD.
Code to display in I2C LCD
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x20,16,2);
void setup() {
lcd.init();
lcd.clear();
lcd.backlight();
lcd.setCursor(2,0);
lcd.print("This is");
lcd.setCursor(2,1);
lcd.print("LCD I2C display");
}
void loop() {}
By,
Dr. M Kanagasabapathy
Associate Professor
Department of Chemistry
Rajapalayam Rajus’ College
Madurai Kamaraj University
Rajapalayam Tamil Nadu (IN)