This library allows interfacing with an 18-pin RGB LCD display backlight connected directly to an Arduino board. It enables the user to control the RGB backlight using Arduino. This library is meant to be used alongside the LiquidCrystal library.
On the RGB LCD display module, set pin 15 to HIGH. Pin 16 is red, pin 17 is green and pin 18 is blue. This sketch will loop through the different colors and display the color name. The code is based on a function that can be used to control the colors on an RGB LED.
- Download the library .zip file from the latest release.
- In the Arduino IDE, go to
Sketch
>Include Library
>Add .ZIP Library...
. - Select the downloaded .zip file.
- Open the Arduino IDE.
- Go to
Tools
>Manage Libraries...
. - In the Library Manager, type "LCD_BacklightRGB" into the search bar.
- Find the "LCD_BacklightRGB" library in the list and click on it.
- Click the
Install
button.
#include <LiquidCrystal.h>
#include "LCD_BacklightRGB.h"
// Set up the LiquidCrystal library
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
// Set up the LCD_BacklightRGB library
const int redPin = 6, greenPin = 9, bluePin = 10;
LCD_BacklightRGB backlight(redPin, greenPin, bluePin);
void setup() {
// Initiate the LCD.
lcd.begin(16, 2);
// Initiate the RGB pins.
backlight.begin();
// Set the brightness level (0 - 255)
backlight.setBrightness(130);
// Set the backlight using RGB values.
backlight.setRGB(0, 255, 0);
lcd.print("Green!");
delay(500);
lcd.clear();
}
void loop() {
// Add your loop code here.
}
Here are some of the 18-pin RGB displays that I found available:
- The Adafruit RGB LCD displays available in backlight positive and backlight negative.
- This one from Winstar that I found on Amazon.