#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 leftSide = 0;
int rightSide = 320;
uint16_t lineColor = ILI9341_RED; // Color of the circle
void setup() {
Serial.begin(115200);
// Initialize the screen
tft.begin();
tft.setRotation(2); // Rotate screen for landscape mode
tft.fillScreen(ILI9341_BLACK);
}
void loop() {
lineColor = random(0x001F, 0xFFFF); // New random color
// Draw the circle
tft.drawLine(0,leftSide,240,rightSide,lineColor);
// tft.drawLine(leftSide,0,rightSide,320,lineColor);
leftSide++;
rightSide--;
if(leftSide > 320){
leftSide = 0;
}
if(rightSide < 0){
rightSide = 320;
}
}