The shield is really easy to use. Once you have attached the LCD of choice, plug it onto the Arduino and download our library from github. The example included shows how to use the RGB backlight control and reading from the keypad.

Download the Library

To interface with the LCD and buttons you must use our library which translates the commands through the port expander

Open up the Arduino library manager:

Search for the Adafruit RGB LCD Shield 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

Adjusting Contrast

The shield uses a character LCD with an external contrast potentiometer. The first time you use it, adjust the potentiometer in the bottom right until you see the text clearly. If you don't upload code to the Arduino, some boxes will appear instead
If you don't see any text on the LCD, be sure to try twisting the orange contrast potentiometer until the text appears. You may have to turn it all the way around from one side to the other until you see text

Shared Pins

The I2C pins are shared with other pins, and each Arduino type has a different sharing scheme. Those pins cannot be used for anything else than I2C when this shield is used!
Uno/Duemilanove/Diecimila - I2C pins are also the same pins as Analog 4 and Analog 5
Mega 1280 and 2560 - I2C pins are also the same pins as Digital 20 and 21
Leonardo and other 32u4-based - I2C pins are also the same pins as Digital 2 and 3

Writing Your Own Sketches

The Adafruit_RGBLCDShield library is a derivative of the LiquidCrystal library that comes with Arduino so you can call any of the functions that you're used to and they'll work just the same.

There are two extra functions you may want to use. One is lcd.setBacklight(color); which will change the backlight color assuming you have an RGB LCD on. At this time, the library does not do any PWM on the RGB backlight, so you can select from 8 different colors (inlcuding OFF) - if you place these #define's at the top of your sketch you can simply call whichever color you want to appear.

// These #defines make it easy to set the backlight color
#define OFF 0x0
#define RED 0x1
#define YELLOW 0x3
#define GREEN 0x2
#define TEAL 0x6
#define BLUE 0x4
#define VIOLET 0x5
#define WHITE 0x7 
Another extra of the shield is a 4-way directional keypad plus select button. This will let you design your own control interface for 'stand-alone' Arduino projects. All the buttons are read at once when you call lcd.readButtons(); which returns a variable that has individual bits set for the buttons. You can easily test for which buttons were held down at the time of the readButtons() call by using bitwise & as seen in this code snippet.

Note that the library handles button debouncing internally.  There is no need to debounce the buttons in your code.
uint8_t buttons = lcd.readButtons();

  if (buttons) {
    if (buttons & BUTTON_UP) {
      lcd.setBacklight(RED);
    }
    if (buttons & BUTTON_DOWN) {
      lcd.setBacklight(YELLOW);
    }
    if (buttons & BUTTON_LEFT) {
      lcd.setBacklight(GREEN);
    }
    if (buttons & BUTTON_RIGHT) {
      lcd.setBacklight(TEAL);
    }
    if (buttons & BUTTON_SELECT) {
      lcd.setBacklight(VIOLET);
    }
  }

Using with Monochrome Displays

Displays with monochrome backlights are controlled by the RED pin and will only respond to colors that have RED in them (RED, YELLOW, VIOLET). For these displays, you can use ON and OFF instead as in the snippet below:
uint8_t buttons = lcd.readButtons();

  if (buttons) {
    lcd.clear();
    lcd.setCursor(0,0);
    if (buttons & BUTTON_UP) {
      lcd.print("UP ");
      lcd.setBacklight(ON);
    }
    if (buttons & BUTTON_DOWN) {
      lcd.print("DOWN ");
      lcd.setBacklight(OFF);
    }

Detached Usage

If you want to have the shield disconnected from the Arduino (say to panel mount it) or if you want to use it with a different type of processor board, its very easy!

Just power the 5V pin with 5V, common ground to GND and then connect the SCL labeled pin (top left) to I2C clock and SDA to I2C data. Those are the only four wires you need to control the entire shield.

  • On Uno-shaped Arduinos, SCL is also connected to Analog 5 and SDA is connected to Analog 4.
  • On Mega Arduinos, SCL is also connected to Digital 21 and SDA is connected to Digital 20.
  • On Leonardo Arduinos, SCL is also connected to Digital 3 and SDA is connected to Digital 2.
Important: Wire +5V and GND to the shield pins shown in the pictures! The GND pin next to the 5v pin is NOT connected. You must use the one next to the VIN pin!

This guide was first published on Jul 29, 2012. It was last updated on Jul 30, 2012.

This page (Arduino Usage) was last updated on Jul 30, 2012.

Text editor powered by tinymce.