#include <Adafruit_ILI9341.h>
#include <Adafruit_GFX.h>
#include <SPI.h>
#define TFT_RST 8
#define TFT_DC 9
#define TFT_CS 10
#define LED_SIZE 20
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
void clearScreen() {
tft.fillScreen(ILI9341_BLACK);
}
void drawLED(int x, int y, uint16_t color) {
tft.fillRoundRect(x, y, LED_SIZE, LED_SIZE, 5, color);
}
void chasingLEDAnimation(int numChases, int chaseDelay) {
uint16_t colors[] = {
ILI9341_RED,
ILI9341_BLUE,
ILI9341_GREEN,
ILI9341_YELLOW,
ILI9341_MAGENTA,
ILI9341_CYAN,
ILI9341_WHITE
};
int numColors = sizeof(colors) / sizeof(colors[0]);
for (int i = 0; i < numChases; i++) {
for (int j = 0; j < numColors; j++) {
drawLED(j * (LED_SIZE + 5), 120 - LED_SIZE / 2, colors[j]);
delay(chaseDelay);
clearScreen();
}
}
}
void setup() {
tft.begin();
tft.setRotation(3);
tft.fillScreen(ILI9341_BLACK);
clearScreen();
chasingLEDAnimation(5, 500); // Chasing the 7 different colored LEDs 5 times with a delay of 500 milliseconds
}
void loop() {
// Your main code (if any) goes here
}
led chasing on tft code by arvind.
अरविन्द पाटील 21/11/23 .