#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
// Pin definitions for ESP32
#define TFT_DC 2
#define TFT_CS 15
#define TFT_RST 4
// Initialize the display using Hardware SPI (Pins 23 and 18 are default)
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
void setup() {
Serial.begin(115200);
Serial.println("ILI9341 Test!");
tft.begin();
// Rotate screen to landscape
tft.setRotation(1);
// Clear screen with a dark blue background
tft.fillScreen(ILI9341_NAVY);
// Set text properties
tft.setCursor(20, 100);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(3);
tft.println("Hello World!");
tft.setCursor(20, 140);
tft.setTextColor(ILI9341_YELLOW);
tft.setTextSize(2);
tft.println("ESP32 TFT Test");
}
void loop() {
// Simple color cycle to test refresh rate
tft.fillCircle(280, 200, 20, ILI9341_RED);
delay(500);
tft.fillCircle(280, 200, 20, ILI9341_GREEN);
delay(500);
}