Introduction
Have you been fed up with Black/White LCD screen? Do you want to try a colorful one? DFRobot I2C 16x2 Arduino LCD with RGB Backlight Display module will bring you a new experience about screen. It comes with RGB full color backlight, which has 16 million kinds of color. Usually, Arduino LCD display projects will run out of pin resources easily, especially with Arduino Uno. And it is also very complicated with the wire soldering and connection. This I2C 16x2 LCD Screen is using an I2C communication interface. It means it only needs 4 pins for the LCD display: VCC, GND, SDA, SCL. It will saves at least 4 digital / analog pins on Arduino. And Gravity interface make it easier to use with our Gravity: IO expansion shield.
Specification
- Operating Voltage: 3.3V ~ 5.0V
- Operating Current: ≤60mA
- Display: 16 * 2
- Communication: I2C
- Backlight: RGB adjustable backlight (16 million)
- Operating Temperature: -20 to 70 ℃
- Storage Temperature: -30 to 80 ℃
- Dimension: 87.0 * 32.0 * 13.0mm/3.42 * 1.26 * 0.51 inches
Board Overview
Num | Label | Description |
---|---|---|
1 | VCC | 3.3~5.0V |
2 | GND | GND |
3 | SCL | I2C-SCl |
4 | SDA | I2C- SDA |
Tutorial
Connect all parts as the diagram, upload the sample code into your UNO, then you can input RGB values to adjust backlit color.
Requirements
Hardware
- DFRduino UNO (or similar) x 1
- Gravity IO expansion Shield x1
- Gravity: I2C LCD1602 RGB Backlight Module x1
- M-M/F-M/F-F Jumper wires
Software
- Arduino IDE, Click to Download Arduino IDE from Arduino®
Connection Diagram
Sample Code
Please download the LCD library: DFRobot RGB LCD. About How to install Libraries in Arduino IDE
/*!
* @file SetColor.ino
* @brief Serial port input Format:255 255 255,There is no end or newline
* @copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
* @licence The MIT License (MIT)
* @maintainer [yangfeng](feng.yang@dfrobot.com)
* @version V1.0
* @date 2021-09-24
* @url https://github.com/DFRobot/DFRobot_RGBLCD1602
*/
#include "DFRobot_RGBLCD1602.h"
char dtaUart[15];
char dtaLen = 0;
/*
Change the RGBaddr value based on the hardware version
-----------------------------------------
Moudule | Version| RGBAddr|
-----------------------------------------
LCD1602 Module | V1.0 | 0x60 |
-----------------------------------------
LCD1602 Module | V1.1 | 0x6B |
-----------------------------------------
LCD1602 RGB Module | V1.0 | 0x60 |
-----------------------------------------
LCD1602 RGB Module | V2.0 | 0x2D |
-----------------------------------------
*/
DFRobot_RGBLCD1602 lcd(/*RGBAddr*/0x2D ,/*lcdCols*/16,/*lcdRows*/2); //16 characters and 2 lines of show
void setup() {
Serial.begin(115200);
/**
* @brief initialize the LCD and master IIC
*/
lcd.init();
// Print a message to the LCD.
lcd.print("set color");
}
void loop() {
if(dtaLen == 11) {
int r = (dtaUart[0]-'0')*100 + (dtaUart[1] - '0')*10 + (dtaUart[2] - '0'); // get r
int g = (dtaUart[4]-'0')*100 + (dtaUart[5] - '0')*10 + (dtaUart[6] - '0');
int b = (dtaUart[8]-'0')*100 + (dtaUart[9] - '0')*10 + (dtaUart[10] - '0');
dtaLen = 0;
/**
* @brief set RGB
* @param r red range(0-255)
* @param g green range(0-255)
* @param b blue range(0-255)
*/
lcd.setRGB(r, g, b);
Serial.println("get data");
Serial.println(r);
Serial.println(g);
Serial.println(b);
Serial.println();
}
}
void serialEvent() {
while(Serial.available()) {
dtaUart[dtaLen++] = Serial.read();
}
}
When uploaded the codes into UNO, open serial monitor, set baud rate to 115200 and select no EOF.
Note: you have to reset the mainboard for every input. The RGB range is 0-255.
![Result 1](https://dfimg.dfrobot.com/nobody/wiki/2671e283a440edc1d76f32d7531974de.png "Result 1")
Input by a group of 4 numbers. For instance, for 12302540123, the input result will be 123,254,123.
![](https://dfimg.dfrobot.com/5ea64bf6cf1d8c7738ad2881/wiki/86fd58df38305da85dcd979e370dd997.png)
![Result 2-1](https://dfimg.dfrobot.com/nobody/wiki/b6d8dd9a2ddf921ce327823bb1e54f6b.png "Result 2-1")
### Expected Result
The backlit color of the LCD1602 module changes according to the input value.
## FAQ
| For any questions, advice or cool ideas to share, please visit the [**DFRobot Forum**](https://www.dfrobot.com/forum/). |
| ---------------------------------------------------------------------------------------------------------------------- |
## More Documents
- [LCD1602 RGB Backlight Module Datasheet](https://github.com/DFRobot/DFRobot_RGBLCD/raw/master/DFR0464 Datasheet.pdf)
- [Arduino Library (Github Repository)](https://github.com/DFRobot/DFRobot_RGBLCD)