#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <SPI.h>
#define TFT_CS 10
#define TFT_DC 9
#define TFT_RST -1 // RST can be left unconnected
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
void setup() {
Serial.begin(115200);
tft.begin();
tft.setRotation(3); // Adjust the rotation if needed
tft.fillScreen(ILI9341_BLACK); // Fill the screen with black color
}
void loop() {
// Display filled circles, squares, and triangles
displayFilledCircles();
delay(2000); // Pause for 2 seconds
tft.fillScreen(ILI9341_BLACK); // Clear the screen
displayFilledSquares();
delay(2000); // Pause for 2 seconds
tft.fillScreen(ILI9341_BLACK); // Clear the screen
displayFilledTriangles();
delay(2000); // Pause for 2 seconds
tft.fillScreen(ILI9341_BLACK); // Clear the screen
displayText();
delay(2000); // Pause for 2 seconds
tft.fillScreen(ILI9341_BLACK); // Clear the screen
}
void displayFilledCircles() {
// Display filled circles at different positions
tft.fillCircle(80, 80, 30, ILI9341_RED);
tft.fillCircle(160, 120, 20, ILI9341_GREEN);
tft.fillCircle(40, 160, 25, ILI9341_BLUE);
}
void displayFilledSquares() {
// Display filled squares at different positions
tft.fillRect(40, 40, 60, 60, ILI9341_YELLOW);
tft.fillRect(120, 80, 40, 40, ILI9341_CYAN);
tft.fillRect(200, 120, 50, 50, ILI9341_MAGENTA);
}
void displayFilledTriangles() {
// Display filled triangles at different positions
tft.fillTriangle(80, 30, 140, 70, 40, 70, ILI9341_ORANGE);
tft.fillTriangle(160, 30, 220, 70, 120, 70, ILI9341_PURPLE);
tft.fillTriangle(40, 110, 100, 150, 0, 150, ILI9341_WHITE);
}
void displayText() {
// Display text in yellow color
tft.setTextColor(ILI9341_YELLOW);
tft.setTextSize(2);
tft.setCursor(30, 100);
tft.print("Arvind 29/11/23");
}