In this Instructable you are going to see how to connect i2c lcd display to arduino and how to print on lcd display.
Each I2C bus consists of two signals: SCL and SDA. SCL is the clock signal, and SDA is the data signal. The clock signal is always generated by the current bus master; some slave devices may force the clock low at times to delay the master sending more data (or to require more time to prepare data before the master attempts to clock it out). This is called “clock stretching” and is described on the protocol page.
To connect 16×2 LCD display to Arduino we use i2c PCF 8574T module. This module expands Arduino pins and allow connection of display using only two Arduino pins.
I2C module has four pins: GND – ground, VCC – 5V power, SDA – data signal, SCL – clock signal. Connect SDA to A4 pin on Arduino, and SCL to A5 pin:
GND <---> GND VCC <---> 5V SDA <---> A4 SCL <---> A5
For working with display on Arduino we need two libraries: Wire.h, LiquidCrystal_I2C.h.
Wire.h is standard Arduino IDE library, and LiquidCrystal_I2C.h is the library for work with LCD displays. You can download it from official Arduino project website: https://www.arduino.cc/reference/en/libraries/liquidcrystal-i2c/
And here is the source code of simple sketch, which write text on 16×2 LCD display:
#include <Wire.h> #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x27,16,2); void setup() { lcd.init(); lcd.backlight(); lcd.setCursor(0,0); // set cursor to 1 symbol of 1 line lcd.print("Arduino Lessons:"); lcd.setCursor(0,1); // set cursor to 1 symbol of 2 line lcd.print("www.andjey.info"); } void loop() { }