#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <SPI.h>
// TFT parameters
#define TFT_CS 10
#define TFT_RST 9
#define TFT_DC 8
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
#define TFT_WIDTH 320
#define TFT_HEIGHT 240
#define SQUARE_SIZE 20
void setup() {
tft.begin();
tft.setRotation(3); // Adjust if necessary
tft.fillScreen(ILI9341_BLACK);
drawSquares();
drawAttractiveDesign();
}
void loop() {
// Main loop can remain empty
}
void drawSquares() {
for (int sideLength = 200; sideLength > 0; sideLength -= 20) {
drawRainbowBackground();
// Draw the square in red
int x = TFT_WIDTH / 2 - sideLength / 2;
int y = TFT_HEIGHT / 2 - sideLength / 2;
tft.fillRect(x, y, sideLength, sideLength, ILI9341_RED);
delay(500);
// Clear the square by filling it with the background color
tft.fillRect(x, y, sideLength, sideLength, ILI9341_BLACK);
}
}
void drawAttractiveDesign() {
for (int i = 0; i < 35; i++) {
uint16_t randomColor = tft.color565(random(255), random(255), random(255));
int x = TFT_WIDTH / 2;
int y = TFT_HEIGHT / 2;
tft.drawCircle(x, y, 100, randomColor);
delay(100);
tft.fillScreen(ILI9341_BLACK);
}
// Display text "by Arvind" in white color
tft.setCursor(TFT_WIDTH / 2 - 30, TFT_HEIGHT - 20);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2);
tft.print("by Arvind");
tft.setCursor(TFT_WIDTH / 2 +80, TFT_HEIGHT +80);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2);
tft.print("by Arvind");
}
void drawRainbowBackground() {
for (int i = 0; i < TFT_WIDTH; i++) {
float hue = (float)i / TFT_WIDTH;
uint16_t color = tft.color565(hue * 255, 255, 255 * (1 - hue)); // Simplified HSV to RGB conversion
tft.drawLine(i, 0, i, TFT_HEIGHT, color);
}
delay(500);
}