#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#define TFT_DC 4
#define TFT_CS 5
#define TFT_MOSI 6
#define TFT_CLK 7
#define TFT_CTRL 45
#define TFT_RST 48
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST);
const char* message = "I AM ARVIND FROM INDIA 91700336035";
int msgIndex = 0;
unsigned long previousMillis = 0;
const long interval = 400; // Typing effect interval
bool ranGraphics = false;
void setup() {
Serial.begin(115200);
Serial.println("Welcome to ESP32-S3 with Graphics!");
pinMode(TFT_CTRL, OUTPUT);
digitalWrite(TFT_CTRL, HIGH);
tft.begin();
// Set MADCTL for display orientation
const uint8_t mode = 0x48;
tft.sendCommand(ILI9341_MADCTL, &mode, 1);
tft.fillScreen(ILI9341_BLACK);
tft.setCursor(88, 60);
tft.setTextColor(ILI9341_RED);
tft.setTextSize(3);
tft.println("ESP32-S3");
delay(1000);
}
void loop() {
if (!ranGraphics) {
runGraphicsTest();
ranGraphics = true;
delay(1500);
tft.fillScreen(ILI9341_BLACK);
tft.setCursor(36, 106);
}
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
if (message[msgIndex] == '\n') {
tft.setCursor(36, tft.getCursorY() + 20); // Next line
} else {
tft.print(message[msgIndex]);
}
if (message[msgIndex] != '\0') {
msgIndex++;
} else {
// Restart typing animation
tft.fillRect(36, 106, 200, 60, ILI9341_BLACK);
tft.setCursor(36, 106);
msgIndex = 0;
}
}
}
void runGraphicsTest() {
tft.fillScreen(ILI9341_BLACK);
// Draw rainbow bars
int barHeight = tft.height() / 7;
tft.fillRect(0, 0 * barHeight, tft.width(), barHeight, tft.color565(255, 0, 0)); // Red
tft.fillRect(0, 1 * barHeight, tft.width(), barHeight, tft.color565(255, 127, 0)); // Orange
tft.fillRect(0, 2 * barHeight, tft.width(), barHeight, tft.color565(255, 255, 0)); // Yellow
tft.fillRect(0, 3 * barHeight, tft.width(), barHeight, tft.color565(0, 255, 0)); // Green
tft.fillRect(0, 4 * barHeight, tft.width(), barHeight, tft.color565(0, 0, 255)); // Blue
tft.fillRect(0, 5 * barHeight, tft.width(), barHeight, tft.color565(75, 0, 130)); // Indigo
tft.fillRect(0, 6 * barHeight, tft.width(), barHeight, tft.color565(148, 0, 211)); // Violet
delay(500);
// Draw shapes
tft.fillCircle(60, 100, 30, ILI9341_CYAN);
tft.drawTriangle(160, 60, 130, 160, 190, 160, ILI9341_MAGENTA);
tft.fillRoundRect(60, 180, 120, 40, 10, ILI9341_YELLOW);
}