#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
// Pin definitions
#define TFT_CS 10
#define TFT_DC 9
#define TFT_RST -1 // You can also connect this to the ESP32 reset pin
// Color definitions
#define BLACK ILI9341_BLACK
#define WHITE ILI9341_WHITE
#define RED ILI9341_RED
#define GREEN ILI9341_GREEN
#define BLUE ILI9341_BLUE
#define YELLOW ILI9341_YELLOW
// Initialize the ILI9341 display
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
void setup() {
Serial.begin(115200);
Serial.println("TFT Display Test");
tft.begin();
tft.setRotation(1); // Set the display rotation (0-3)
tft.fillScreen(BLACK); // Fill the screen with black color
drawGraphics();
displayCodeByArvind();
}
void loop() {
animateText();
}
void drawGraphics() {
// Draw some shapes with increased size
tft.fillRect(10, 10, 70, 70, RED); // Increased size by 40%
tft.fillCircle(100, 100, 42, GREEN); // Increased size by 40%
tft.drawTriangle(150, 150, 200, 80, 250, 150, BLUE); // Adjusted to make it larger
// Draw some text
tft.setTextColor(YELLOW);
tft.setTextSize(4); // Increased text size by 40%
tft.setCursor(10, 200);
tft.print(" Arvind!");
tft.setTextSize(1.4); // Increased text size by 40%
tft.setCursor(10, 220);
tft.print("Welcome to TFT Display");
}
void animateText() {
static int16_t x = 0;
static int16_t y = 180;
static int8_t xDir = 1;
static int8_t yDir = 1;
// Clear the previous text position
tft.fillRect(x, y, 112, 14, BLACK); // Adjusted size to accommodate larger text
// Update text position
x += xDir;
y += yDir;
// Bounce text off the edges
if (x <= 0 || x >= tft.width() - 112) { // Adjusted width for larger text
xDir = -xDir;
}
if (y <= 0 || y >= tft.height() - 14) { // Adjusted height for larger text
yDir = -yDir;
}
// Draw the text at the new position
tft.setCursor(x, y);
tft.setTextColor(YELLOW);
tft.setTextSize(2); // Increased text size by 40%
tft.print("Moving Text");
delay(30);
}
void displayCodeByArvind() {
tft.setTextColor(WHITE);
tft.setTextSize(2); // Set text size
tft.setCursor(10, 250); // Position the text
tft.print("CODE BY ARVIND");
}