#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#define TFT_CS 10
#define TFT_DC 9
#define TFT_RST 8
#define BLACK 0x0000
#define RED 0xF800
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
void setup() {
Serial.begin(9600);
// Initializing TFT display:
tft.begin();
}
void loop() {
// Fill TFT Screen with a color:
tft.fillScreen(BLACK);
delay(1000);
// Fill the entire screen with red:
tft.fillRect(0, 0, 320, 480, RED);
delay(500);
// Draw a rectangle that covers the entire screen:
tft.drawRect(0, 0, 320, 480, YELLOW);
delay(1000);
// Set cursor:
tft.setCursor(80, 25);
// Set text color:
tft.setTextColor(WHITE);
// Set text size:
tft.setTextSize(2);
// Print text to TFT display:
tft.println("EEWORLDONLINE");
delay(2000);
// Draw Lines
for (int i = 65; i < 480; i += 7) {
tft.drawLine(0, 240, 320, i, WHITE);
delay(100);
}
// Draw Circles
for (int i = 60; i > 5; i -= 5) {
tft.drawCircle(160, 240, i, WHITE);
delay(200);
}
// Draw rectangles
for (int i = 100; i > 30; i -= 10) {
tft.drawRect(110, 190, i, i, WHITE);
delay(200);
}
// Draw Triangles
for (int i = 10; i < 50; i += 5) {
tft.drawTriangle(
160, 360 + i,
110 + i, 460 - i,
210 - i, 460 - i,
WHITE
);
}
delay(2000);
// Fill the entire screen with white:
tft.fillScreen(WHITE);
delay(500);
// Draw a rectangle that covers the entire screen:
tft.drawRect(0, 0, 320, 480, YELLOW);
delay(500);
// Set cursor:
tft.setCursor(40, 30);
// Set text size:
tft.setTextSize(2);
// Set text color:
tft.setTextColor(RED);
// Print text to TFT display:
tft.println("Thanks for watching!");
// Draw a rectangle for the second text block:
tft.fillRect(0, 100, 320, 70, YELLOW);
tft.setCursor(10, 100);
tft.setTextSize(2);
tft.setTextColor(RED);
tft.println("Stay connected with us");
tft.println(" @ EngineersGarage.com");
delay(5000);
}