Using LCD1602 with I2C Interface - Arduino Tutorial
This tutorial demonstrates how to interface a 1602 LCD display with Arduino using an I2C module, making it easier and cleaner to connect compared to traditional parallel wiring. With just four connections (VCC, GND, SDA, SCL), you can fully control the display and show text or sensor data in your Arduino projects.

All required code, wiring diagrams, and library download links are provided below this article.
What is LCD1602 with I2C?
The LCD1602 is a 16-character, 2-row display commonly used in embedded systems. Normally, it requires 6 to 10 pins to operate, but by adding an I2C module, only two data lines (SDA and SCL) are needed for communication. This drastically simplifies wiring and leaves more pins free on the Arduino for other components.
Wiring the LCD1602 to Arduino

Here's how to wire your LCD1602 with the I2C module to an Arduino Uno:
-
VCC- 5V
-
GND - GND
-
SDA - A4
-
SCL -A5
Caption: LCD1602 connected to Arduino via I2C using only 4 wires.
- Code Explanation Displaying Text on the LCD
The code below initializes the LCD, enables the backlight, and prints text in a loop.
cppCopyEdit#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);
-
Wire.h: Required for I2C communication. -
LiquidCrystal_I2C.h: Library to control the LCD using I2C. -
lcd(0x27, 16, 2): Initializes the LCD at address0x27with 16 columns and 2 rows.
cppCopyEditvoid setup()
{
lcd.begin(); // Initialize LCD
lcd.backlight(); // Turn on backlight
}
-
lcd.begin()prepares the LCD for use. -
lcd.backlight()turns on the display's backlight.
cppCopyEditvoid loop()
{
lcd.clear(); // Clear previous content
lcd.print("Robojax"); // Print on first line
lcd.setCursor(0,1); // Move cursor to beginning of second line
lcd.print("Hello World!"); // Print on second line
delay(500); // Wait for 0.5 seconds
}
-
The screen is refreshed every half second.
-
You could also display other data, like time or sensor values.
Installing the Required Library
You must install the LiquidCrystal_I2C library:
-
Open Arduino IDE
-
Go to Sketch > Include Library > Manage Libraries
-
Search for
LiquidCrystal_I2C -
Click Install
Once installed, you're ready to compile and upload the code.
Chapters From the Video
-
00:00 - Start
-
00:35 -LCD1602 and I2C Module Explained
-
04:37 -Wiring Explained
-
05:35 -Downloading LCD1602-I2C Library
-
07:13 -Code Explained for LCD1602
/*
This is code for LCD1602 Display with I2C module
* Watch the video for this code https://youtu.be/q9YC_GVHy5A
* Permission granted to share this code given that this
* note is kept with the code.
* Disclaimer: this code is "AS IS" and for educational purposes only.
* This library is based on work done by DFROBOT (www.dfrobot.com).
*/
/*
* This code has been modified from the Arduino library
* Updated by Ahmad Nejrabi on Jan 20, 2018 at 11:09
* in Ajax, Ontario, Canada
* for Robojax.com
*
* This is code for LCD1602 Display with I2C module
* which can display text on the screen.
*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup()
{
// Robojax code for LCD with I2C
// initialize the LCD,
lcd.begin();
// Turn on the backlight and print a message.
lcd.backlight();
// Robojax code for LCD with I2C
}
void loop()
{
//start of loop Robojax code for LCD with I2C
lcd.clear();
lcd.print("Robojax");
lcd.setCursor (0,1); // go to start of 2nd line
lcd.print("Hello World!");
//lcd.print(millis() / 1000);
delay(500);
//end of loop Robojax code for LCD with I2C
}
|||您可能需要的东西
-
易趣从eBay购买Arduino入门套件ebay.us
-
全球速卖通从AliExpress购买Arduino入门套件s.click.aliexpress.com
-
BanggoodPurchase LCD1602 display from Banggoodbanggood.com
资源与参考
-
外部
-
外部
-
外部
-
外部Purchase LCD1602 display from Banggoodbanggood.com
文件📁
Arduino 库(zip 格式)
-
LCD1602 LCD Arduino library from Robojax
robojax-LCD1602-I2C-library-master.zip0.01 MB
Fritzing 文件
-
LCD LCD1602-I2C module with 4 wires
LCD1602-I2C.fzpz0.01 MB