Example Code for Arduino-Icon Display
Last revision 2026/01/18
The icon.ino code shows us some common icons.
Hardware Preparation
- FireBeetle ESP32-E (or similar) x 1
- 1.8Inch 128×160 TFT LCD Display with MicroSD Card Slot x1
- Wires
Software Preparation
- Arduino IDE
- DFRobot GDL Library
- About how to install the library?
- DFRobot_GDL API, click to learn more.
Wiring Diagram
The following figure shows two ways of connection: SPI and GDI.

Other Preparation Work
- For using GDI, please make sure your controller has GDI interface.
- It is recommended to use Arduino version 1.8.10 and above.
- If the SD card slot is not well connected, the initialization may fail, and it will succeed after unplugging and plugging again.
- Arduino UNO is not recommended for memory reasons.
- All the Demos of this product are stored in the file of DFRobot_GDL->ST7735_128x160-.
- Before burning the Demo, please open the corresponding substantiation function (DFRobot_ST7789_128x160_HW_SPI)

Sample Code
#include "DFRobot_GDL.h"
#include "Icon.h"
//Custom communication pins
/*M0*/
#if defined ARDUINO_SAM_ZERO
#define TFT_DC 7
#define TFT_CS 5
#define TFT_RST 6
/*ESP32 ESP8266*/
#elif defined(ESP32)
#define TFT_DC D2
#define TFT_CS D6
#define TFT_RST D3
/*ESP8266*/
#elif defined(ESP8266)
#define TFT_DC D4
#define TFT_CS D6
#define TFT_RST D5
/* AVR series mainboard */
#else
#define TFT_DC 2
#define TFT_CS 3
#define TFT_RST 4
#endif
DFRobot_ST7735_128x160_HW_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST);
/* M0 mainboard DMA transfer */
//DFRobot_ST7735_128x160_DMA_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST);
void setup() {
Serial.begin(115200);
screen.begin();
}
void loop() {
int w = screen.width();
int h = screen.height();
int a = millis()/1000;
uint16_t color = 0x00FF;
screen.fillScreen(COLOR_RGB565_WHITE);
while(1) {
for(int i = 0;i < 12; i++){
screen.fillRect(16,16,w-16*2,35, COLOR_RGB565_WHITE);
screen.setTextWrap(false);
screen.setTextColor(0x30FF);
screen.setTextSize(2);
screen.setCursor(30, 30);
screen.println("Time:");
screen.setTextColor(0x00FF);
screen.setTextSize(2);
screen.setCursor(90, 30);
a = millis()/1000;
screen.println(a, 1);
screen.fillRoundRect(w/2-48-12, h/2-10, 32*3+12*2, 32+8*2, 20, 0x0000);
for(int x = 0; x<16 ;x++)
screen.drawFastVLine(/*x=*/x,/*y=*/0,/*h=*/h,/*color=*/color);
for(int y = 0; y<16 ;y++)
screen.drawFastHLine(/*x=*/16,/*y=*/y,/*w=*/w-16*2,/*color=*/color);
for(int x = w-1; x>=w-16 ;x--)
screen.drawFastVLine(x,0,h, color);
for(int y = h-1; y>=h-16 ;y--)
screen.drawFastHLine(16,y,w-16*2,color);
screen.drawXBitmap(/*x=*/w/2-48,/*y=*/h/2,/*bitmap gImage_Bitmap=*/gImage[i],/*w=*/32,/*h=*/32,color+=0x0700);
delay(1000);
screen.drawXBitmap(/*x=*/w/2-16,/*y=*/h/2,/*bitmap gImage_Bitmap=*/gImage[i+1],/*w=*/32,/*h=*/32,color+=0x0700);
delay(1000);
screen.drawXBitmap(/*x=*/w/2+16,/*y=*/h/2,/*bitmap gImage_Bitmap=*/gImage[i+2],/*w=*/32,/*h=*/32,color+=0x0700);
delay(1000);
}
}
}
Result

Was this article helpful?
