Introduction
Accustomed to the same LCD screen, do you want to have a different experience? DFRobot LCD1602 will bring you a new visual feeling, It is not the same as the previous LCD monochrome screen, supports RGB full-color font, can provide 16 million kinds of color combinations. DFRobot Gravity I2C 16x2 Arduino LCD with RGB Font Display use universal Gravity I2C interface, it means only two communication lines, you can realize communication and backlight control. The LCD screen can display 2x16 characters, support screen scrolling, cursor movement and other functions. Through dedicated Arduino library, you can complete all the design without cumbersome wiring and complex code.
Specification
- Operating Voltage: 3.3V~5.0V
- Operating Current: ≤60mA
- Display Description: 16*2
- Communication Mode: IIC/I2C
- Backlight: RGB can adjust backlight
- OperatingTemperature: -20 to 70℃
- Storage Temperature: -30 to 80℃
- Dimension: 87.0*32.0*13.0mm/3.43*1.26*0.51in
Board Overview
Num | Label | Description |
---|---|---|
1 | VCC | Positive Pole |
2 | GND | Negative Pole |
3 | SCL | IIC Clock Line |
4 | SDA | IIC Data Line |
Tutorial
Follow the pin description to connect the hardware, and download the sample code to UNO, after upload is successful, you can see the LCD display and backlight gradient.
Requirements
Hardware
- DFRduino UNO R3 (or similar) x 1
- Gravity: I/O Expansion x1
- Sensor cable
Software
- Arduino IDE, Click to Download Arduino IDE from Arduino®
Connection Diagram
Sample Code
Click here to download [DFRobot LCD Library(Github)] 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.
Input by a group of 4 numbers. For instance, for 12302540123, the input result will be 123,254,123.
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. |
---|