#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
// =====================================================
// CYD ESP32-2432S028
// GRAPHICS CAPABILITY SHOWCASE
// CODE BY ARVIND
// =====================================================
// ---------------- TFT PINS ----------------
#define TFT_CS 15
#define TFT_DC 2
#define TFT_MOSI 13
#define TFT_MISO 12
#define TFT_SCK 14
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
// ---------------- RGB LED -----------------
#define LED_R 4
#define LED_G 16
#define LED_B 17
// ---------------- DISPLAY -----------------
#define W 320
#define H 240
// =====================================================
// RGB CONTROL
// =====================================================
void setRGB(bool r, bool g, bool b) {
digitalWrite(LED_R, r ? LOW : HIGH);
digitalWrite(LED_G, g ? LOW : HIGH);
digitalWrite(LED_B, b ? LOW : HIGH);
}
// =====================================================
// START SCREEN
// =====================================================
void startScreen() {
tft.fillScreen(ILI9341_BLACK);
// Gradient background
for (int y = 0; y < H; y++) {
uint16_t c = tft.color565(
y,
0,
255 - y
);
tft.drawFastHLine(0, y, W, c);
}
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(3);
tft.setCursor(45, 80);
tft.print("CODE BY ARVIND");
tft.setTextColor(ILI9341_YELLOW);
tft.setTextSize(2);
tft.setCursor(40, 130);
tft.print("AI CENTRE NANDURBAR");
// Animated circles
for (int r = 10; r < 100; r += 10) {
tft.drawCircle(
W / 2,
H / 2,
r,
ILI9341_CYAN
);
delay(60);
}
delay(3000);
}
// =====================================================
// END SCREEN
// =====================================================
void endScreen() {
tft.fillScreen(ILI9341_BLACK);
for (int y = 0; y < H; y++) {
uint16_t c = tft.color565(
255 - y,
y,
50
);
tft.drawFastHLine(0, y, W, c);
}
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(3);
tft.setCursor(30, 90);
tft.print("SUBSCRIBE");
tft.setCursor(85, 130);
tft.print("&");
tft.setCursor(65, 170);
tft.print("SHARE");
// Glow effect
for (int i = 0; i < 20; i++) {
tft.drawRect(
10 + i,
10 + i,
W - (20 + i * 2),
H - (20 + i * 2),
tft.color565(
random(255),
random(255),
random(255)
)
);
}
delay(5000);
}
// =====================================================
// RAINBOW LINES
// =====================================================
void rainbowLines() {
tft.fillScreen(ILI9341_BLACK);
int cx = W / 2;
int cy = H / 2;
for (int a = 0; a < 360; a += 2) {
float rad = a * DEG_TO_RAD;
int x = cx + cos(rad) * 160;
int y = cy + sin(rad) * 120;
uint16_t c = tft.color565(
127 + 127 * sin(rad),
127 + 127 * sin(rad + 2),
127 + 127 * sin(rad + 4)
);
tft.drawLine(cx, cy, x, y, c);
}
}
// =====================================================
// RANDOM CIRCLES
// =====================================================
void circlesFX() {
tft.fillScreen(ILI9341_BLACK);
for (int i = 0; i < 80; i++) {
int x = random(W);
int y = random(H);
int r = random(5, 35);
uint16_t c = tft.color565(
random(255),
random(255),
random(255)
);
tft.fillCircle(x, y, r, c);
tft.drawCircle(x, y, r, ILI9341_WHITE);
}
}
// =====================================================
// TRIANGLES
// =====================================================
void trianglesFX() {
tft.fillScreen(ILI9341_BLACK);
for (int i = 0; i < 60; i++) {
int x1 = random(W);
int y1 = random(H);
int x2 = random(W);
int y2 = random(H);
int x3 = random(W);
int y3 = random(H);
uint16_t c = tft.color565(
random(255),
random(255),
random(255)
);
tft.fillTriangle(
x1, y1,
x2, y2,
x3, y3,
c
);
}
}
// =====================================================
// SPIRAL
// =====================================================
void spiralFX() {
tft.fillScreen(ILI9341_BLACK);
float angle = 0;
float radius = 1;
int cx = W / 2;
int cy = H / 2;
while (radius < 120) {
int x = cx + cos(angle) * radius;
int y = cy + sin(angle) * radius;
uint16_t c = tft.color565(
127 + 127 * sin(angle),
127 + 127 * sin(angle + 2),
127 + 127 * sin(angle + 4)
);
tft.fillCircle(x, y, 2, c);
angle += 0.18;
radius += 0.12;
}
}
// =====================================================
// PIXEL BLAST
// =====================================================
void pixelBlast() {
tft.fillScreen(ILI9341_BLACK);
for (long i = 0; i < 25000; i++) {
int x = random(W);
int y = random(H);
uint16_t c = tft.color565(
random(255),
random(255),
random(255)
);
tft.drawPixel(x, y, c);
}
}
// =====================================================
// STARFIELD
// =====================================================
void starfieldFX() {
tft.fillScreen(ILI9341_BLACK);
for (int i = 0; i < 5000; i++) {
int x = random(W);
int y = random(H);
int b = random(100,255);
uint16_t c = tft.color565(b,b,b);
tft.drawPixel(x, y, c);
}
}
// =====================================================
// SETUP
// =====================================================
void setup() {
Serial.begin(115200);
SPI.begin(
TFT_SCK,
TFT_MISO,
TFT_MOSI,
TFT_CS
);
tft.begin();
tft.setRotation(1);
pinMode(LED_R, OUTPUT);
pinMode(LED_G, OUTPUT);
pinMode(LED_B, OUTPUT);
setRGB(false, false, false);
randomSeed(analogRead(0));
startScreen();
}
// =====================================================
// LOOP
// =====================================================
void loop() {
// =========================================
// RAINBOW LINES
// =========================================
setRGB(true,false,false);
rainbowLines();
delay(2200);
// =========================================
// CIRCLES
// =========================================
setRGB(false,true,false);
circlesFX();
delay(2200);
// =========================================
// TRIANGLES
// =========================================
setRGB(false,false,true);
trianglesFX();
delay(2200);
// =========================================
// SPIRAL
// =========================================
setRGB(true,false,true);
spiralFX();
delay(2200);
// =========================================
// PIXEL BLAST
// =========================================
setRGB(false,true,true);
pixelBlast();
delay(2200);
// =========================================
// STARFIELD
// =========================================
setRGB(true,true,false);
starfieldFX();
delay(2200);
// =========================================
// END SCREEN
// =========================================
setRGB(true,true,true);
endScreen();
}Loading
esp32-2432s028r
esp32-2432s028r
https://wokwi.com/projects/464273894944083969