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
68 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 No-Code Indoor Air Quality Monitor with Separate... By Tyler Cooper beginner Trinket Temperature & Humidity LCD Display By Anne Barela beginner Light Meter By Dan Malec beginner Trinket Ultrasonic Rangefinder By Anne Barela beginner Faz-Wrench - Five Nights at Freddy's By Ruiz Brothers intermediate Adafruit Metro M7 1011 with AirLift By lady ada beginner Adafruit INA23x DC Current Voltage Power Monitor By Liz Clark beginner Adafruit ESP32-C6 Feather By Liz Clark intermediate Adafruit TSC2046 SPI Resistive Touch Screen Controller By Liz Clark beginner Adafruit ENS160 MOX Gas Sensor By Liz Clark beginner Adafruit NeoKey BFF By Liz Clark beginner Adafruit HDC302x Precision Temperature & Humidity... By Liz Clark beginner Adafruit High Power Infrared LED Emitter By Liz Clark beginner Adafruit SEN54 or SEN55 Adapter Breakout By Liz Clark beginner Your browser does not support the video tag. This links to the guide Funhouse Door Alert with Email Notification. Funhouse Door Alert with Email Notification By John Park beginner