The first option we'll show is how to use the I2C interface on the backpack. We'll be showing how to connect with an Arduino, for other microcontrollers please see our MCP23008 library code for the commands to send to the I2C I/O expander. I2C is nice because it only uses two pins, and you can put multiple I2C devices on the same two pins.

So for example, you could have up to 8 LCD backpacks+LCDs all on two pins! The bad news is that you have to use the 'hardware' I2C pins. You can't change those pins and you can't use them for reading analog data. If you absolutely need those two pins, use SPI (see the next section).

For this, we'll need to connect four wires: GND, 5V, CLK (clock) and DAT (data) via the STEMMA QT connection or the terminal block pins.

Install Adafruit_LiquidCrystal

To begin reading sensor data, you will need to download the Adafruit_LiquidCrystal library from the Arduino library manager.

Open up the Arduino library manager:

Search for the Adafruit LiquidCrystal library and install it

We also have a great tutorial on Arduino library installation at:

Load Demo

Restart the IDE and load up the Adafruit_LiquidCrystal->HelloWorld_i2c demo

Upload the sketch. You should see the backlight turn on when the Arduino resets. If you don't see any characters, adjust the Contrast trim potentiometer with a mini-screwdriver until you see the text clearly

The default HelloWorld sketch blinks the backlight as well as updating the text.

If you see the backlight blinking that means your connection to the I2C port is OK but the contrast is too low or too high, or the LCD data pins are not solidly connected.

Check the contrast first by gently twisting the mini trim potentiometer, if that doesn't help, recheck your soldering and resolder all 16 of the LCD pins!

Once you're done, you can remove the blinking LED backlight code:


Changing the I2C Address

If you want to have more than one LCD backpack device each one needs to have a unique 'address'. You can set the address by jumpering the A0 A1 and A2 solder jumpers.  By default, no jumpers are soldered, giving an address of 0x20 (offset 0). If you want to have an address of 0x23 (0x20 + offset 3) you would solder A0 (bit 0) and A1 (bit 1) for an address offset of "011" = 3 in binary. 

Then, in the code change:

// Connect via i2c, default address #0 (A0-A2 not jumpered)
LiquidCrystal lcd(0);
// Connect via i2c, address #3 (A0&A1 jumpered)
LiquidCrystal lcd(3);

This guide was first published on Aug 27, 2012. It was last updated on Oct 29, 2018.

This page (Arduino I2C Use) was last updated on Aug 27, 2012.

Text editor powered by tinymce.