#include <Adafruit_ILI9341.h>
#include <Adafruit_GFX.h>
#include <SPI.h>
#define TFT_RST 8
#define TFT_DC 9
#define TFT_CS 10
#define TFT_LED 7
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
void clearScreen() {
tft.fillScreen(ILI9341_BLACK);
}
void animateTriangle() {
int x1 = 120; // Initial x-coordinate of the first point
int y1 = 30; // Initial y-coordinate of the first point
int x2 = 30; // Initial x-coordinate of the second point
int y2 = 200; // Initial y-coordinate of the second point
int x3 = 210; // Initial x-coordinate of the third point
int y3 = 200; // Initial y-coordinate of the third point
int size = 200; // Initial size of the triangle
int colorStep = 5; // Smaller step for smoother color transition
while (size > 0) {
for (int i = 0; i < size; i++) {
int currX1 = x1 + (x2 - x1) * i / size;
int currY1 = y1 + (y2 - y1) * i / size;
int currX2 = x1 + (x3 - x1) * i / size;
int currY2 = y1 + (y3 - y1) * i / size;
// Calculate rainbow color based on the position in the triangle
uint16_t color = tft.color565(
255 * (1 + sin(colorStep * i * PI / 180.0)) / 2,
255 * (1 + sin(colorStep * (i + 120) * PI / 180.0)) / 2,
255 * (1 + sin(colorStep * (i + 240) * PI / 180.0)) / 2
);
tft.drawLine(currX1, currY1, currX2, currY2, color);
}
size -= 10; // Reduce the size by 10 pixels
delay(100);
clearScreen();
}
// Write "arvind" in the empty space
writeArvind();
}
// Write "arvind" in the empty space
void writeArvind() {
// Set cursor position and text color
tft.setCursor(80, 120); // Adjust the coordinates based on your desired position
tft.setTextColor(ILI9341_WHITE); // Text color in white
// Print the text
tft.print("Arvind");
}
void setup() {
tft.begin();
tft.setRotation(3);
tft.fillScreen(ILI9341_BLACK);
pinMode(TFT_LED, OUTPUT);
digitalWrite(TFT_LED, HIGH);
animateTriangle(); // Updated function for drawing a colorful triangle
}
void loop() {
// Your main code (if any) goes here
}