#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
// Pin-Belegung für ESP32 in Wokwi
#define TFT_DC 2
#define TFT_CS 15
#define TFT_RST 4
// Die Pins SCK (18) und MOSI (23) werden standardmäßig von der SPI-Lib genutzt
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
void setup() {
Serial.begin(115200);
Serial.println("ILI9341 Test gestartet...");
tft.begin();
tft.setRotation(1); // Querformat
// Hintergrund füllen
tft.fillScreen(ILI9341_BLACK);
// Text ausgeben
tft.setCursor(20, 30);
tft.setTextColor(ILI9341_YELLOW);
tft.setTextSize(3);
tft.println("ESP32 + ILI9341");
tft.setCursor(20, 70);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(2);
tft.println("Wokwi Simulation");
}
void loop() {
// Ein einfaches animiertes Rechteck
for(int i=0; i<200; i+=5) {
tft.drawRect(20 + i, 120, 50, 50, ILI9341_CYAN);
delay(50);
tft.drawRect(20 + i, 120, 50, 50, ILI9341_BLACK); // Löschen für Animation
}
}