Hello, my name is Max and this is part 12 of my Arduino Tutorial Series
In this video, i'm gonna show you how to drive
this 16x2 lcd with only two pins of your arduino
 
Many of you own one of these 16x2 lcds
and know how frustrating it is to wire 12 different pins
and how limiting it is when you need 7 pins of your board to drive it
This amount of pins is needed, because your arduino is
communicating via a parallel interface with the display
You need pins to select the correct register,
to switch between read/write mode and to transfer the data.
You can reduce this amount by using a I2C-Backpack
I features a chip, that handles all this required actions and
takes care of the parallel interface of the lcd.
The arduino communicates via I2C with the backpack.
I2C is a serial bus that requires only two signal lines and
was developed for communication between ICs.
I2C is also known as TWI (Two-Wire Interface)
Using the module we can reduce the amount of required I/O-pins from 7 to only 2
On top of that, we need less parts, because
the module already features a potentiometer to adjust contrast
The module can also be used with bigger LCDs
This makes it great for fast prototyping without having to deal with
a crazy amount of wiring to display some simple data.
You can find the I2C backpack on ebay.
Sometimes the backpack comes already assembled with a display.
To use the module you need a library that handles the communication between
Arduino and I2C module
There a few libraries available, you can find a link in the description.
Lets look at the schematic
GND to GND 
+5V with VCC
A4 to SDA
A5 to SCL
 
 
Note that the SDA and SCL pins on your arduino board can differ
I put the most common pins in the video description
If you are not sure which pins to use, just google your board name + i2c pins
Lets look a the Code
First you include the needed Libraries Wire.h and LiquidCristal_I2C.h
Every device on the i2c bus needs a unique adress
create a LiquidCrystal_I2C object and pass the adress as a parameter
16 and 2 stand for the amount of columns and rows of your display
if you dont know the adress of your module
try 0x27, for most modules this should work
if it doesnt work, watch my quicktip video about how
to find the correct adress of any i2c device
from this point on the code is very similiar to what we are used to from the standard lcd-library
in setup() we initialize the display with lcd.begin()
then we can print on the display with lcd.print(text)
we can clear the display with lcd.clear()
and set the Cursor to any position with lcd.setCursor(coloumn, row)
 
last but not least, we can turn the backlight on and off with lcd.backlight() or lcd.noBacklight()
this feature is useful if you want to save energy to e.g. increas e batterytime
that's it for this video
Thank you very much for watching!
If you liked the video, please subscribe and give a thumbs up. See you next time!
