#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
// Pin Definitions for the ILI9341 display
#define TFT_CS 10
#define TFT_RST 9
#define TFT_DC 8
// Screen dimensions
#define SCREEN_WIDTH 240
#define SCREEN_HEIGHT 320
// Text parameters
#define TEXT_SIZE 2
#define TEXT_COLOR ILI9341_PINK
#define TEXT "DVD"
// ILI9341 display object
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
// Text position
int16_t textX = 0;
int16_t textY = 0;
int16_t textDirX = 1; // Text direction along X-axis
int16_t textDirY = 1; // Text direction along Y-axis
void setup() {
Serial.begin(9600);
// Initialize the ILI9341 display
tft.begin();
tft.setRotation(3); // Adjust screen rotation if needed
// Fill the screen with black
tft.fillScreen(ILI9341_BLACK);
// Set text color and size
tft.setTextColor(TEXT_COLOR);
tft.setTextSize(TEXT_SIZE);
}
void loop() {
// Clear previous text
tft.fillRect(textX, textY, strlen(TEXT) * 6 * TEXT_SIZE, 8 * TEXT_SIZE, ILI9341_BLACK);
// Update text position
textX += textDirX;
textY += textDirY;
// Check if text hits edges
if (textX + strlen(TEXT) * 6 * TEXT_SIZE >= SCREEN_WIDTH || textX <= 0) {
textDirX = -textDirX;
}
if (textY + 8 * TEXT_SIZE >= SCREEN_HEIGHT || textY <= 0) {
textDirY = -textDirY;
}
// Draw text
tft.setCursor(textX, textY);
tft.print(TEXT);
// Delay for smoother animation
delay(10);
}