#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#define TFT_SCK 13
#define TFT_MOSI 11
#define MISO 12
#define TFT_CS 10
#define TFT_DC 9
#define TFT_RST 8
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
void drawColorGradientSquare();
void displayColorSquareGrid();
void displayColorTriangles();
void drawCircles();
void writeDiagonally();
int colorRangeMap(int value, int in_min, int in_max, int out_min, int out_max);
void setup() {
Serial.begin(115200);
delay(500);
delay(1000);
// Initialize the TFT display
tft.begin();
tft.setRotation(3); // Adjust the rotation if necessary
}
void loop() {
drawColorGradientSquare();
delay(5000);
tft.fillScreen(ILI9341_BLACK);
displayText("Arvind Patil", 2000);
displayColorSquareGrid();
delay(2500);
tft.fillScreen(ILI9341_BLACK);
displayText("Arvind Patil", 2000);
displayColorTriangles();
delay(2000);
tft.fillScreen(ILI9341_BLACK);
displayText("Arvind Patil", 2000);
drawCircles();
displayText("Arvind Patil", 2000);
writeDiagonally();
displayText("Arvind Patil", 2000);
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_RED);
tft.setTextSize(3);
tft.setCursor(10, 50);
tft.print("by Arvind");
delay(3000);
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(3);
tft.setCursor(10, 50);
tft.print("by Arvind");
delay(3000);
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_BLUE);
tft.setTextSize(3);
tft.setCursor(10, 50);
tft.print("by Arvind");
delay(3000);
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(2);
tft.setCursor(10, 220);
tft.print("HAVE A NICE DAY");
delay(3000);
}
void displayText(const char* text, int duration) {
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2);
tft.setCursor(10, 220);
tft.print(text);
delay(duration);
}
void drawColorGradientSquare() {
int centerX = 120;
int centerY = 160;
int initialSize = 150;
int sizeStep = 25;
for (int size = initialSize; size > 0; size -= sizeStep) {
int halfSize = size / 2;
for (int x = centerX - halfSize; x <= centerX + halfSize; x++) {
for (int y = centerY - halfSize; y <= centerY + halfSize; y++) {
int distanceX = abs(x - centerX);
int distanceY = abs(y - centerY);
int maxDistance = max(distanceX, distanceY);
int color = colorRangeMap(maxDistance, 0, halfSize, ILI9341_RED, ILI9341_BLUE);
tft.drawPixel(x, y, color);
}
}
}
displayText("Arvind Patil", 2000);
}
int colorRangeMap(int value, int in_min, int in_max, int out_min, int out_max) {
return (value - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
void displayColorSquareGrid() {
int side = 150;
int spacing = 30;
for (int i = 0; i < 10; ++i) {
uint16_t color = tft.color565(i * 20, i * 10, 255 - i * 15);
tft.fillRect(10 + i * spacing, 10 + i * spacing, side, side, color);
side -= 5;
delay(2500);
}
displayText("Arvind Patil", 2000);
}
void displayColorTriangles() {
int side = 240;
int spacing = 30;
for (int i = 0; i < 10; ++i) {
uint16_t color = tft.color565(i * 20, 255 - i * 10, i * 15);
int x0 = 80 + i * spacing;
int y0 = 30 + i * spacing;
int x1 = 140 + i * spacing;
int y1 = 70 + i * spacing;
int x2 = 40 + i * spacing;
int y2 = 70 + i * spacing;
tft.fillTriangle(x0, y0, x1, y1, x2, y2, color);
side -= 5;
delay(2000);
}
displayText("Arvind Patil", 2000);
}
void drawCircles() {
uint16_t colors[] = {ILI9341_RED, ILI9341_ORANGE, ILI9341_YELLOW, ILI9341_GREEN, ILI9341_BLUE, ILI9341_INVCTR, ILI9341_CASET};
int x = tft.width() / 2;
int y = tft.height() / 2;
int dia = 200;
for (int i = 0; i < 7; i++) {
tft.fillCircle(x, y, dia / 2, colors[i]);
delay(2000);
dia -= 25;
}
displayText("Arvind Patil", 2000);
}
void writeDiagonally() {
tft.setTextColor(ILI9341_YELLOW);
tft.setTextSize(3);
int x = 40;
int y = 60;
char text[] = "by Arvind 26 jan24 😀";
for (int i = 0; i < strlen(text); i++) {
tft.write(text[i]);
x += 20;
y += 20;
tft.setCursor(x, y);
}
displayText("Arvind Patil", 2000);
}