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.
8
I2C LCD Backpack
Hitachi’s HD44780 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 PCF8574 (from NXP) which is a general purpose bidirectional 8 bit I/O port expander that uses the I2C protocol. The PCF8574 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 PCF8574T (SO16 package of PCF8574 in DIP16 package) with a default slave address of 0x27. If your backpack holds a PCF8574AT chip, then the default slave address will change to 0x3F. In short, your backpack is based on PCF8574T and the address connections (A0-A1- A2) are not bridged with solder it will have the slave address 0x27.
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.
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 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.

The Code;
  1. /*
  2. Project: I2C LCD Backpack Arduino Experiment
  3. By: T.K.Hareendran/TechNode Protolabz
  4. For: http://www.electroschematics.com
  5. Includes: Library from https://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_
  13. I2C.h" // Added library*
  14. //Set the pins on the I2C chip used for LCD connections
  15. //ADDR,EN,R/W,RS,D4,D5,D6,D7
  16. LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7); // 0x27 is the default I2C bus address of the backpack-see article
  17. void setup()
  18. {
  19. // Set off LCD module
  20. lcd.begin (16,2); // 16 x 2 LCD module
  21. lcd.setBacklightPin(3,POSITIVE); // BL, BL_POL
  22. lcd.setBacklight(HIGH);
  23. }
  24. void loop()
  25. {
  26. lcd.home (); // Set cursor to 0,0
  27. lcd.print("protolabz"); // Custom text
  28. lcd.setCursor (0,1); // Go to home of 2nd line
  29. lcd.print(millis());
  30. delay(1000); // Blinks of backlight
  31. lcd.setBacklight(LOW); // Backlight off
  32. delay(500);
  33. lcd.setBacklight(HIGH); // Backlight on
  34. delay(1000); 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.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!


Post a Comment

 
Top