The Arduino LCD Backpack makes it easy and very convenient to use LCDs in your microcontroller project. Using the LCD backpack has a lot of advantages compared to connecting your LCD directly to your microcontroller. The advantages are as follows:
- Firstly, you save a lot of I/O pins. The Arduino I2C LCD backpack uses the Inter-integrated Circuit (I2C or I2C) Protocol , meaning you only need two I/O pins for your Serial Data (SDA) and Serial Clock (SCL) lines. The usual means of connecting the LCD to your microcontroller would have required you to use at least 6 I/O pins. Using the LCd backpack frees up 4 pins to use for other purposes.
- Secondly you use less jumper cables and wires, making your project neater, sving you a lot of unnecessary hardware debugging and helping you keep your sanity!
The backpack is very cheap and common to find. Here are the parts we are going to be using for this tutorial.
- Hitachi HD44780 driver compatible LCD
- Arduino Uno
- Some jumper wires
- A breadboard (optional)
This is how the I2C LCD Backpack looks like. You can solder it directly to the back of an LCD which is the most advisable way. If you are just prototyping however, you can just plug it into the breadboard as shown in this tutorial.
Below is a Fritzing image of how to connect the LCD to an Arduino. Connect SDA and SCL of the backpack to Arduino pins A4 and A5 respectively. Then connect VCC to 5v and GND to GND on yout Arduino and you are good to go.
In order to use the I2C LCD backpack with an Arduino, you will have to download the Liquid Crystal I2C library and extract it into your Arduino libraries folder. Check out this Sparkfun tutorial on how to install an Arduino library if you don’t know how to do so already.
Here is the Sketch below originally by T.K. Hareendran and modified by me.
By: T.K.Hareendran/TechNode Protolabz
Modified By: Isaac Sesi - Current City
Date: December 2016
#include "Wire.h" // For I2C
#include "LCD.h" // For LCD
#include "LiquidCrystal_I2C.h" // Added library*
//Set the pins on the I2C chip used for LCD connections
LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7); // 0x27 is the default I2C bus address of the backpack-see article
// Set off LCD module
lcd.begin (16,2); // 16 x 2 LCD module
lcd.setBacklightPin(3,POSITIVE); // BL, BL_POL
lcd.home (); // Set cursor to 0,0
lcd.print("NANA ADDO HAS"); // Custom text
lcd.setCursor (0,1); // Go to home of 2nd line
lcd.print("FINALLY COME "); // Custom text
You can also download the code from github.
If everything goes well, you should have something like this as your final circuit.
NOTE: Every I2C device has a special address that enables the Arduino to communicate with it which you have to specify as shown below. By default, the I2C bus address for the LCD backpack is 0x27.
LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7); // 0x27 is the default I2C bus address of the backpack
However in some cases it may be different and you may have to find the address manually. Fortunately there is a simple Arduino sketch that you can run while having your I2C device connected and it will show you the address of the LCD backpack.
Here is a link to the I2C scanner tutorial to help you find the specific address of your I2C device.
So, thats it!
I hope you enoyed this tutorial. Please leave a comment. The feedback gives me a lot of motivation to do more tutorials.