Arduino Projects Online

Complete Details about the Arduino

Arduino I2C LCD Backpack Introductory Tutorial

Arduino I2C LCD Backpack Introductory Tutorial Assume that you are moving towards a complex microcontroller project bundled with blinkers, beepers, and a display panel. To link a standard 16×2 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!

Arduino I2C LCD Backpack Introductory Tutorial

 

I2C LCD Backpack

Hitachi’s

based 16×2 character LCD are very cheap and widely available, and is an essential part for any project that displays information. Using the LCD backpack, desired data can be displayed on the LCD through the I2C bus. In principle, such backpacks are built aorund

(from NXP) which is a general purpose bidirectional 8 bit I/O port expander that uses the I2C protocol. The

is a silicon CMOS circuit provides general purpose remote I/O expansion (an 8-bit quasi-bidirectional) for most microcontroller families via the two-line bidirectional bus (I2C-bus). Note that most backpack modules are centered around

T (SO16 package of

in DIP16 package) with a default slave address of 0x27. If your backpack holds a

AT chip, then the default slave address will change to 0x3F. In short, your backpack is based on

T and the address connections (A0-A1- A2) are not bridged with solder it will have the slave address 0x27.

 

Arduino I2C LCD Backpack Introductory Tutorial

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.

Arduino I2C LCD Backpack Introductory Tutorial

I2C LCD Display

Now let’s get started. At first you need to solder the backpack to your LCD module. Ensure that the backpack pins are straight and fit in the LCD module, then solder in the first pin while keeping the backpack in the same plane with the LCD. Once you have finished the soldering work , get four jumper wires and connect the LCD module to your Arduino as per the instruction given below.

Arduino I2C LCD Backpack Introductory Tutorial

Arduino Setup

For this experiment it is necessary to download 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: I2C LCD Backpack Arduino Experiment
  3. By: T.K.Hareendran
  4. For: //www.arduinopoint.wordpress.com
  5. Includes: Library from //bitbucket.org/fmalpartida/new-liquidcrystal/downloads*
  6. Hardware/Controller: See article
  7. Software/Sketch: Precisely adapted – Ref: Internet
  8. Date: December 2015
  9. */
  10. #include “Wire.h” // For I2C
  11. #include “LCD.h” // For LCD
  12. #include “LiquidCrystal_I2C.h” // Added library*
  13. //Set the pins on the I2C chip used for LCD connections
  14. //ADDR,EN,R/W,RS,D4,D5,D6,D7
  15. LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7); // 0x27 is the default I2C bus address of the backpack-see article
  16. void setup()
  17. {
  18. // Set off LCD module
  19. lcd.begin (16,2); // 16 x 2 LCD module
  20. lcd.setBacklightPin(3,POSITIVE); // BL, BL_POL
  21. lcd.setBacklight(HIGH);
  22. }
  23. void loop()
  24. {
  25. lcd.home (); // Set cursor to 0,0
  26. lcd.print(“protolabz”); // Custom text
  27. lcd.setCursor (0,1); // Go to home of 2nd line
  28. lcd.print(millis());
  29. delay(1000); // Blinks of backlight
  30. lcd.setBacklight(LOW); // Backlight off
  31. delay(500);
  32. lcd.setBacklight(HIGH); // Backlight on
  33. delay(1000);
  34. }

If you are 100% sure that everything is okay, but you don’t see any characters on the display, try to adjust the contrast control pot of the backpack and set it a position where the characters are bright and the background does not have dirty boxes behind the characters. Following is a partial view of author’s experiment with the above described code. Since the display used by the author is a very clear bright “black on yellow” type, it is very difficult to get a good catch due to polarization effects.

Arduino I2C LCD Backpack Introductory Tutorial

Lab Note

The hardware configuration described have been tested with an Arduino UNO R3, a 16×2 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 official documentation can be downloaded from the download section of this repository 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!

Also Check:

Updated: 14th July 2017 — 12:02 pm
Arduino Projects Online © 2017 Frontier Theme