Hey what’s up.
I’m Aymaan Rahman and in this video I’m going to show you how to use an LCD i2c display
with an Arduino Uno.
Lets get right into it!
The pins on the LCD display are labeled as Ground(GND), VCC, SDA and SCL.
The ground connection we connect to the ground pin on the Uno.
The VCC goes to the 5volt pin on Uno.
The SDA pin is the I2C data and that is connected to pin A4, the SCL pin is the I2C clock and
that is attached to A5.
We need to install an Arduino library for the LCD Display, I’m using one called Arduino
LiquidCrystal I2C and its available to download from Github, I’ll provide the link in the
description.
Once its downloaded, open the Arduino IDE, select Sketch, include library, add .zip library,
then select the zip file that we downloaded.
I2C can support multiple devices, each device has a 7 bit address to identify it, its not
always obvious what the address of the device is but to find it, we can run a I2C scanner
sketch, I’ll put a link for it in the description.
We just need to upload the sketch to the arduino, open the serial monitor and it will display
the I2C address of the LCD Display.
So now we know the address of the LCD and we’ve installed the library, we can try
a simple sketch.
In the Arduino IDE, go to file, examples, under examples from custom libraries, click
on Arduino liquid crystal I2C library master, then click on hello world, this prints “Hello
World” on the LCD display.
The first line includes the wire library, the second line includes the Liquid Crystal
I2C library that we installed earlier.
On the third line, the I2C address is specified, its the address that we got from the scanner
sketch, and the dimensions of the display is specified on the 2nd and 3rd parameter,
the display I’m using is a 16x2 which means that it can display 16 characters per line
and it has 2 lines.
lcd.begin initializes the interface with the lcd display and lcd.print prints to the lcd
display, so let’s upload the sketch and see what happens.
If you want multiple messages showing up one after another, you can use delays in the loop
and lcd.clear which clears the lcd display and positions the cursor on the upper-left
corner and print for each unique message.
Here I wanted a message “I am powered by Arduino” but this message is too long and
the arduino word would be pushed to the far right side of the display and wouldn't appear,
so I used lcd.setCursor and changed the line to 1 which means the second line on the display,
0 is the first line.
So the word Arduino will be printed on the second line.
You can also push the message more to the right side by changing this value.
So let’s upload this code.
It works!
If the LCD Display is not working, you might need to adjust the contrast potentiometer
on the back of the display.
If you got value out of this video, please hit the like button!
And subscribe as more awesome videos are coming soon!
If you want to support me directly, please go to patreon.com/aymaanrahman05 and sign
up for a membership.
Thank you very much for watching!
See you in the next video!
Bye!