Arduino I2C LCD Backpack Introductory Tutorial
Arduino I2C LCD Backpack Introductory Tutorial
(http://www.electroschematics.com/wp-content/uploads/2015/12/I2C-
LCD-Backpack-Primer.png)
(https://www.facebook.com/sharer/sharer.php?u=http://www.electroschematics.com/12459/arduino-i2c-lcd-
backpack-introductory-tutorial/) (https://twitter.com/share) (/qa/)
Assume that you are moving towards a complex microcontroller project bundled with blinkers, beepers, and a display panel.
To link a standard 162 LCD directly with the microcontroller, for instance Arduino, you would need atleast 6 I/O pins to talk
to the LCD. However, if you use an LCD module with I2C interface, you only need 2 lines to process the display information.
Now a days, it is not necessary to buy an expensive I2C LCD for this task because readymade serial backpack modules for
standard LCDs are available at reasonable rates. You can use them with LCD modules that have a HD44780 compatible
interface with various screen sizes by attaching to the back of the LCD module. This allows connection to your Arduino (or
other microcontroller) using only four channels. Yippee!
http://www.electroschematics.com/12459/arduinoi2clcdbackpackintroductorytutorial/ 1/7
16/12/2016 ArduinoI2CLCDBackpackIntroductoryTutorial
(http://www.electroschematics.com/wp-content/uploads/2015/12/I2C-LCD-Backpack-Primer.png)
(http://www.electroschematics.com/wp-
content/uploads/2015/12/address-
selection-pads-in-the-lcd-
backpack.png)
(address selection pads in the lcd backpack)
Reference circuit diagram of an Arduino-compatible LCD backpack is shown below. What follows next is information on how
to use one of these inexpensive backpacks to interface with a microcontroller in ways it was exactly intended.
(http://www.electroschematics.com/wp-
content/uploads/2015/12/reference-circuit-diagram-of-the-lcd-
backpack.png)
http://www.electroschematics.com/12459/arduinoi2clcdbackpackintroductorytutorial/ 2/7
16/12/2016 ArduinoI2CLCDBackpackIntroductoryTutorial
(reference circuit diagram of the lcd backpack)
(http://www.electroschematics.com/wp-
content/uploads/2015/12/lcd-display-to-arduino-wiring.png)
(lcd display to arduino wiring)
Arduino Setup
For this experiment it is necessary to
download (http://www.electroschematics.com/wp-content/uploads/2015/12/Liquid-Crystal-Libray-Download.rar) and install the
Arduino I2C LCD library. First of all, rename the existing LiquidCrystal library folder in your Arduino libraries folder as a
backup, and proceed to the rest of the process.
Next, copy-paste this example sketch for the experiment into the blank code window, verify, and then upload.
1./*
2.Project:I2CLCDBackpackArduinoExperiment
3.By:T.K.Hareendran/TechNodeProtolabz
4.For:http://www.electroschematics.com
5.Includes:Libraryfromhttps://bitbucket.org/fmalpartida/newliquidcrystal/downloads*
6.Hardware/Controller:Seearticle
7.Software/Sketch:PreciselyadaptedRef:Internet
8.Date:December2015
9.*/
10.#include"Wire.h"//ForI2C
11.#include"LCD.h"//ForLCD
12.#include"LiquidCrystal_I2C.h"//Addedlibrary*
13.//SetthepinsontheI2CchipusedforLCDconnections
14.//ADDR,EN,R/W,RS,D4,D5,D6,D7
15.LiquidCrystal_I2Clcd(0x27,2,1,0,4,5,6,7);//0x27isthedefaultI2Cbusaddressofthebackpackseearticle
16.voidsetup()
17.{
18.//SetoffLCDmodule
19.lcd.begin(16,2);//16x2LCDmodule
20.lcd.setBacklightPin(3,POSITIVE);//BL,BL_POL
21.lcd.setBacklight(HIGH);
22.}
23.voidloop()
24.{
25.lcd.home();//Setcursorto0,0
26.lcd.print("protolabz");//Customtext
27.lcd.setCursor(0,1);//Gotohomeof2ndline
28.lcd.print(millis()); (/)
29.delay(1000);//Blinksofbacklight
30.lcd.setBacklight(LOW);//Backlightoff
31.delay(500);
32.lcd.setBacklight(HIGH);//Backlighton
33.delay(1000);
34.}
http://www.electroschematics.com/12459/arduinoi2clcdbackpackintroductorytutorial/ 3/7
16/12/2016 ArduinoI2CLCDBackpackIntroductoryTutorial
(http://www.electroschematics.com/wp-
content/uploads/2015/12/from-authors-workbench.png)
(from authors workbench)
Lab Note
The hardware con guration described have been tested with an Arduino UNO R3, a 162 LCD, and an I2C LCD backpack
purchased from an eBay seller. Further, the example sketch has been fully tested with a 4 bit interface as described using
Arduino IDE0022. Source code for the library used here and its o cial documentation can be downloaded from the download
section of this repository (https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads) which comes in source and with examples
that will get you started. Additionally you have a full description of the library in the docs folder in HTML format that you can
browse. Have fun!
Previous
Arduino with Keypad
Tutorial
(http://www.electroschematics.com/12446/arduino-with-keypad/)
Next
CAN Transceiver for
Automotive
(http://www.electroschematics.com/12468/can-transceiver-for-
automotive/)
Related Tutorials
11This
Comments
website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More (/policy/)
(/)
grswamy12367gmail-com
Thank you very much sir, I wanted to connect some of those pins for rotary encoder to use interrupts.
T.K.Hareendran
Welcome! Note that those 2 pins in your Arduino (SCL,SDA) can also be shared with other I2C based peripherals. Carry on.
grswamy12367gmail-com
Thank you Mr Hareendran for the response. The clari cation I required was : Do the other arguments represent the arduino pin numbers?. If
so will I be able to
use pins mentioned in the bracket for other purposes? (0x27,2,1,0,4,5,6,7). Are they required for communication in addition to SDA and SCL
pins?. Your clari cation will be of great help.
grswamy12367gmail-com
Thank you Mr Hareendran for the response. The clari cation I required was : Do the other arguments represent the arduino pin numbers?. If
so will I be able use pins mentioned in the bracket for other purposes? (0x27,2,1,0,4,5,6,7). Are they required for communication in addition
to SDA and SCL pins?. Your clari cation will be of great help.
T.K.Hareendran
To the best of my knowledge, the arguments (and the display hardware) are not connected with Arduino pins (except SDA & SCL).
So you can use your Arduino I/O as desired. Actually, those arguments are required for the library to send correct signals to
appropriate pins of the IC module!
grswamy12367gmail-com
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More (/policy/)
Thank you Mr Hareendran for the response. The clari cation I required was : Do the other arguments represent the arduino pin numbers?. If
(/) for communication in addition to
so will I be use pins mentioned in the bracket for other purposes? (0x27,2,1,0,4,5,6,7). Are they required
SDA and SCL pins?. Your clari cation will be of great help.
grswamy12367gmail-com
I use arduino mega 2560 r3 with pins 20 and 21 for sda and scl to communicate with i2c lcd backpack
What exactly are the arguements in the brackets other than the address 0x27. (0x27,2,1,0,4,5,6,7) in the following command line.
LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7);
Posted on October 09th 2016 | 11:16 am (http://www.electroschematics.com/12459/arduino-i2c-lcd-backpack-introductory-tutorial/#comment-1901289)
http://www.electroschematics.com/12459/arduinoi2clcdbackpackintroductorytutorial/ 5/7
16/12/2016 ArduinoI2CLCDBackpackIntroductoryTutorial
Posted on October 09th 2016 | 11:16 am (http://www.electroschematics.com/12459/arduino-i2c-lcd-backpack-introductory-tutorial/#comment-1901289)
Log in to Reply (http://www.electroschematics.com/wp-login.php?redirect_to=http%3A%2F%2Fwww.electroschematics.com%2F12459%2Farduino-i2c-lcd-
backpack-introductory-tutorial%2F)
T.K.Hareendran
As you may well know, there are several Character LCD IC modules on the market. So you should use correct initialization code
(might be slightly di erent for each module). After initialization,next is to instantiate the LCD object by calling LiquidCrystal_IC
class constructor. This constructor accepts parameter in following order: addr, en, rw, rs, d4, d5, d6, d7, bl, blpol. Note that the
rst argument (addr) is mandatory,other arguments are optional, if not speci ed they will be set to their default values. Hope this
helps
Lisa
Really cool, I think you can upload your project on openhardware.io for sale.
T.K.Hareendran
@Lisa: Thanks for your feedback, and suggestions!
tkhareendran
While sur ng I found a good I2C FAQ on the web. Ardent readers may nd this very useful:
http://mbouget.perso.neuf.fr/i2c-faq.html (http://mbouget.perso.neuf.fr/i2c-faq.html)
Login
Email
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More (/policy/)
(/)
Password
Remember Me
Log In
http://www.electroschematics.com/12459/arduinoi2clcdbackpackintroductorytutorial/ 6/7
16/12/2016 ArduinoI2CLCDBackpackIntroductoryTutorial
Working With Bootloaders & Build Your Own Bootloader -... (http://www.electroschematics.com/10922/working-
bootloaders-build-bootloader-2/#li-comment-1901857)
"where i can download bootloader"
View More ()
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More (/policy/)
(/)
http://www.electroschematics.com/12459/arduinoi2clcdbackpackintroductorytutorial/ 7/7