#include <TFT_eSPI.h>
#include <SPI.h>
// Pin definitions for XIAO ESP32-C3
#define TFT_MISO 5 // D5
#define TFT_MOSI 6 // D6
#define TFT_SCLK 4 // D4
#define TFT_CS 10 // D10
#define TFT_DC 2 // D2
#define TFT_RST 3 // D3
TFT_eSPI tft = TFT_eSPI();
void setup() {
tft.init();
tft.setRotation(1);
tft.fillScreen(TFT_BLACK);
tft.setTextColor(TFT_YELLOW, TFT_BLACK);
tft.setTextSize(2);
tft.drawString("XIAO ESP32-C3", 60, 20);
tft.drawString("ILI9341 Benchmark", 40, 50);
delay(1000);
}
void loop() {
// 1️⃣ Color fill test
uint16_t colors[] = {TFT_RED, TFT_GREEN, TFT_BLUE, TFT_CYAN, TFT_MAGENTA, TFT_YELLOW, TFT_WHITE};
for (int i = 0; i < 7; i++) {
tft.fillScreen(colors[i]);
delay(300);
}
// 2️⃣ Gradient test
for (int y = 0; y < 240; y++) {
tft.drawFastHLine(0, y, 320, tft.color565(y, 255 - y, y / 2));
}
delay(500);
// 3️⃣ Circle and rectangle test
for (int i = 0; i < 10; i++) {
tft.fillCircle(random(20, 300), random(20, 220), random(10, 40), colors[random(0, 7)]);
tft.fillRect(random(0, 280), random(0, 200), random(20, 60), random(20, 60), colors[random(0, 7)]);
delay(200);
}
// 4️⃣ Line pattern test
tft.fillScreen(TFT_BLACK);
for (int i = 0; i < 320; i += 10) {
tft.drawLine(0, 0, i, 240, TFT_GREEN);
tft.drawLine(320, 240, i, 0, TFT_BLUE);
}
delay(500);
// 5️⃣ Text scroll test
tft.fillScreen(TFT_BLACK);
tft.setTextColor(TFT_WHITE);
for (int y = 240; y > -20; y -= 5) {
tft.fillScreen(TFT_BLACK);
tft.drawString("XIAO ESP32-C3 + ILI9341", 40, y);
delay(50);
}
}
Loading
xiao-esp32-c3
xiao-esp32-c3