
Documentation Center
Figure 10: Installing the LiquidCrystal I2C library
3. After successful installation of the library, you can now copy the following sample code into your Arduino IDE:
4. Select the right Serial Port and upload the code, as shown in Figure 11 and Figure 12.
#
include
LiquidCrystal_I2C
.
h
#
include
Wire
.
h
//initialize the liquid crystal library
//the first parameter is the I2C address
//the second parameter is how many rows are on your screen
//the third parameter is how many columns are on your screen
LiquidCrystal_I2C
lcd
(
0x27
,
16
,
2
);
//change the 0x27 based on the result from the I2C scanner co
void
setup
()
{
lcd
.
init
();
//initialize lcd screen
lcd
.
backlight
();
// turn on the backlight
}
void
loop
()
{
start_display
();
// star
delay
(
1000
);
//wait for a second
lcd
.
clear
();
// clear the LCD content
delay
(
1000
);
//wait for a second
}
void
start_display
(){
lcd
.
setCursor
(
0
,
0
);
// tell the screen to write on the top row
lcd
.
(
"QWIIC"
);
// tell the screen to write "QWIIC" on the top row
lcd
.
setCursor
(
0
,
1
);
// tell the screen to write on the bottom row
lcd
.
(
"EXAMPLE"
);
// tell the screen to write "EXAMPLE" on the bottom row
}
c