#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <SPI.h>
// Pines exactos mapeados según tu esquema de KiCad
#define TFT_CLK 18
#define TFT_MOSI 19
#define TFT_MISO -1 // No se usa para escribir en pantalla
#define TFT_CS 5
#define TFT_DC 16
#define TFT_RST 23
#define TFT_BL 4 // Pin del Backlight
// CONSTRUCTOR MANUAL SPI: Le pasamos todos los pines para que no haya margen de error
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
void setup() {
Serial.begin(115200);
Serial.println("Inicializando simulación de pantalla...");
// Encender el pin de retroiluminación (Backlight)
pinMode(TFT_BL, OUTPUT);
digitalWrite(TFT_BL, HIGH);
// Iniciar pantalla
tft.begin();
tft.setRotation(1); // Orientación horizontal
// Pintar el fondo de azul
tft.fillScreen(ILI9341_BLUE);
// Dibujar texto de prueba
tft.setCursor(30, 60);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(3);
tft.println("CONEXION OK");
tft.setCursor(30, 110);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(2);
tft.println("Simulacion activa!");
}
void loop() {
delay(200);
}