The LCD Display

Author Gravatar Image MIKE BARELA
Adafruit carries many character LCD display varieties with multiple sizes and backlight colors.

The Adafruit I2C / SPI character LCD backpack allows you to control these displays by sending data over the two wire I2C interface. Standard LCDs require a large number of digital pins, straining the capability of even an Arduino Uno. Use of the I2C backpack reduces the pins needed considerably.

This project features a 16x2 display, displaying temperature and humidity without using a great deal of memory (important on a small microcontroller like Trinket).

The I2C backpack may be assembled and placed on the back of the display. See the guide to backpack assembly to prepare your display and the backpack.

The color displays have a couple of extra connectors - pins 16, 17, and 18 control the three color backlights. If you connect pin 16, the I2C will control the red light. You can choose to put a jumper from one of the backlight pins to backpack pin 16 to choose a different color or connect the pins high to keep them on all the time. Making the pin choice before soldering on the backpack allows you the most flexibility in choosing your backlight color.
Or you can just go with a 'classic' blue & white 16x2 LCD
To test the display, wire the DAT pin to Trinket GPIO #0, the CLK pin to Trinket GPIO #2, 5V to the Trinket 5V line and GND to GND.

Ensure your Arduino IDE has the changes for Trinket installed per tutorial Introoducing Trinket to include the hardware folder in your sketch library, the USBtinyISP device driver, and replacing the default ld.exe (dated 2008) with the version dated 2009 to allow for large programs.

The display test program is a variation of the Hello World program. You need to install two libraries for the I2C and LCD functions: TinyWireM and TinyLiquidCrystal repectively. The full size libraries do not have the functions required to talk via the ATTiny85 I2C interface on the Trinket, so similar libraries have been provided.
Ensure you configure the Arduino IDE software for Trinket as noted in the tutorial Introducing Trinket. Also select Trinket 5V and the USBtinyISP programmer in the Arduino Tools menu.
Copy Code
 Demonstration sketch for Adafruit i2c/SPI LCD backpack
 using MCP23008 I2C expander and the Trinket mini microcontroller

 This sketch prints "Hello World!" to the LCD
 and shows a count in seconds.  The circuit:
 * 5V to Trinket 5V pin
 * GND to Trinket GND pin
 * CLK to Trinket pin GPIO #2
 * DAT to Trinket pin GPIO #0

// include the library code:
#include <TinyWireM.h>
#include <TinyLiquidCrystal.h>

// Connect via i2c, default address #0 (A0-A2 not jumpered)
TinyLiquidCrystal lcd(0);

void setup() {
  // set up the LCD
  lcd.begin(16, 2);            // our display has 16 cols, 2 rows
  lcd.setBacklight(HIGH);      // Turn on the backlight
  lcd.print("hello, world!");  // Print a message to the LCD.

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
If you plan on having more than one LCD or I2C device, see Changing the I2C Address for details.

What if I have no display?

Using the contrast potentiometer on the backpack (a small silver bump), turn the dial with a small screwdriver. Change the contrast until you can read the text.
Last updated on 2015-05-04 at 04.27.32 PM Published on 2013-09-28 at 08.15.57 PM