Skip to main content I2C/SPI LCD Backpack Arduino I2C Use
Overview
Pinouts
Which LCD to Use?
Assembly
Arduino I2C Use
Arduino SPI Use
Python & CircuitPython
Python Docs
Downloads
Single page
Feedback? Corrections?
Text View
Primary Products
Your browser does not support the video tag. i2c / SPI character LCD backpack - STEMMA QT / Qwiic $9.95 Add to Cart
Featured Products view all
Standard LCD 20x4 + extras $17.95 Add to Cart
Standard LCD 16x2 + extras $9.95 Add to Cart
67 Beginner Product guide
Arduino I2C Use
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:http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use
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:
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 A0A1 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:
Download File Copy Code // Connect via i2c, default address #0 (A0-A2 not jumpered) LiquidCrystal lcd(0); // Connect via i2c, default address #0 (A0-A2 not jumpered) LiquidCrystal lcd(0); to Download File Copy Code // Connect via i2c, address #3 (A0&A1 jumpered) LiquidCrystal lcd(3); // Connect via i2c, address #3 (A0&A1 jumpered) LiquidCrystal lcd(3);
Page last edited March 08, 2024
Text editor powered by tinymce.
Assembly Arduino SPI Use Related Guides Trinket Temperature & Humidity LCD Display By Anne Barela beginner Trinket Ultrasonic Rangefinder By Anne Barela beginner No-Code Indoor Air Quality Monitor with Separate... By Tyler Cooper beginner New Light Meter By Dan Malec beginner Faz-Wrench - Five Nights at Freddy's By Ruiz Brothers intermediate Your browser does not support the video tag. This links to the guide Adafruit 1.47" Round Rectangle TFT Display. Adafruit 1.47" Round Rectangle TFT Display By M. LeBlanc-Williams beginner Your browser does not support the video tag. This links to the guide Adafruit Hallowing M4. Adafruit Hallowing M4 By Kattni Rembor beginner Fruit Jam IRC Client in CircuitPython By Tim C beginner PB Gherkin 30% keyboard with KMK, CircuitPython, &... By Eva Herrada beginner CircuitScheme - Lisp on CircuitPython By Dave Astels advanced Adafruit BMP580, BMP581, and BMP585 - Temperature... By Tim C beginner Cyber Flower: Digital Valentine By Tony DiCola beginner Adafruit HUZZAH ESP8266 breakout By lady ada intermediate Adafruit TSL2591 High Dynamic Range Digital Light... By lady ada intermediate Your browser does not support the video tag. This links to the guide NeoPixel Infinity Cube. NeoPixel Infinity Cube By Ruiz Brothers beginner