#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
// Define the pins for your display
#define TFT_CS 15
#define TFT_DC 2
#define TFT_MOSI 23
#define TFT_SCLK 18
#define TFT_RST -1 // Use -1 if no reset pin is connected
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
int circleX = 160; // X position of the circle
int circleY = 120; // Y position of the circle
int circleRadius = 5; // Initial radius of the circle
uint16_t circleColor = ILI9341_RED; // Color of the circle
void setup() {
Serial.begin(115200);
// Initialize the screen
tft.begin();
tft.setRotation(1); // Rotate screen for landscape mode
tft.fillScreen(ILI9341_BLACK);
// Set a random starting position and color
circleX = random(20, 300);
circleY = random(20, 220);
circleColor = random(0x001F, 0xFFFF);
}
void loop() {
circleColor = random(0x001F, 0xFFFF); // New random color
// Draw the circle
tft.drawCircle(circleX, circleY, circleRadius, circleColor);
// Increase the radius
circleRadius++;
// Reset the circle when it gets too big
if (circleRadius > 30) {
circleX = random(20, 300); // New random X position
circleY = random(20, 220); // New random Y position
circleRadius = 5; // Reset radius
}
}