Example Code for Arduino-Text and Date/Time Display
Last revision 2026/01/29
This article provides an in-depth tutorial on how to display text and date/time on an Arduino using both I2C and UART communication modes, complete with hardware preparation, software setup, wiring diagrams, and sample code.
Hardware Preparation
- DFRduino UNO R3 (SKU: DFR0216) ×1
- Gravity: I2C&UART Color Display Module (SKU: DFR0997) ×1
- PH2.0-4P cable ×1
- USB cable ×1
Software Preparation
- Download Arduino IDE: Click here to download Arduino IDE
- Download Arduino library: Click here to download DFRobot_LcdDisplay library.
- For Arduino IDE V1.8.19 (or earlier), install the library manually: How to Add a Library?
Wiring Diagram
-
I2C Communication Mode:

Pin Connection Description- Display: + Pin --- (Connect to) --- Controller: 5V
- Display: - Pin --- (Connect to) --- Controller: GND
- Display: C Pin --- (Connect to) --- Controller: SCL
- Display: D Pin --- (Connect to) --- Controller: SDA
-
UART Communication Mode:

Pin Connection Description- Display: + Pin --- (Connect to) --- Controller: 5V
- Display: - Pin --- (Connect to) --- Controller: GND
- Display: R Pin --- (Connect to) --- Controller: 5/TX
- Display: T Pin --- (Connect to) --- Controller: 4/RX
Sample Code
-
Supports displaying text in four languages: Chinese, English, Japanese, and Korean.
-
Display Date and Time: The date has a separate API, but it can also be displayed using text.
#include "DFRobot_LcdDisplay.h"
DFRobot_Lcd_IIC lcd(&Wire, /*I2CAddr*/ 0x2c);
uint8_t labelId = 0;
uint8_t lcdTimeId = 0;
void setup(void){
lcd.begin();
lcd.cleanScreen();
delay(500);
lcd.setBackgroundColor(WHITE);
}
void loop(void)
{
//The fourth parameter is the font size, where 0 represents a font height of 24 pixels and 1 represents a font height of 12 pixels.
//This parameter is only applicable to eChina and eAscii text.
labelId = lcd.drawString( 10, 10, "Hello, World\nhello,World2024\n안녕하세요こんにちは\nПривет мирΓεια σου κόσμε", 0, BLUE);
lcdTimeId = lcd.drawLcdTime(10, 90, 15, 26, 00, 1, BLUE); //Display time
lcd.drawLcdDate(10, 120, 4, 7, 7, 0, BLUE); //Display date
delay(2000);
lcd.updateString( labelId, 10, 10, "Hello, World", 1, BLACK);//Update text
delay(2000);
lcd.updateLcdTime(lcdTimeId, 10, 90, 20, 10, 20, 1, BLACK); //Update time
delay(2000);
lcd.cleanScreen(); //The clean screen API will delete all the displayed content
}
Result

Was this article helpful?
