#include <Adafruit_ILI9341.h>
#include <SPI.h>
#define TFT_CS 10
#define TFT_DC 9
#define TFT_RST 8
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
// Define the emojis as 8x8 pixel arrays
uint8_t emojis[4][5][8] = {
// Set 1
{
{B00011000, B00111100, B01111110, B11011011, B11011011, B01111110, B00111100, B00011000}, // Emoji 1
{B00111100, B01000010, B10100101, B10000001, B10100101, B01000010, B00111100, B00000000}, // Emoji 2
{B00011000, B00111100, B01111110, B11111111, B11111111, B01111110, B00111100, B00011000}, // Emoji 3
{B00111100, B01100110, B11000011, B11111111, B11000011, B01100110, B00111100, B00000000}, // Emoji 4
{B00111100, B01100110, B11011011, B11111111, B11011011, B01100110, B00111100, B00000000} // Emoji 5
},
// Set 2
{
// Add your emojis for set 2 here
},
// Set 3
{
// Add your emojis for set 3 here
},
// Set 4
{
// Add your emojis for set 4 here
}
};
uint16_t colors[4] = {
ILI9341_RED,
ILI9341_GREEN,
ILI9341_BLUE,
ILI9341_YELLOW
};
void setup() {
Serial.begin(9600);
tft.begin();
tft.setRotation(4); // Adjust the rotation if needed
}
void loop() {
// Clear the screen
tft.fillScreen(ILI9341_BLACK);
// Display larger emojis moving horizontally at 20 pixels per second for each set
int scrollSpeed = 20;
for (int i = 0; i < 4; i++) {
displayEmojisHorizontally(i, scrollSpeed);
}
delay(500); // Adjust the delay for smooth movement
}
void displayEmojisHorizontally(int setIndex, int speed) {
int emojiWidth = 8;
int emojiHeight = 8;
int scaleFactor = 5; // Scale factor for making emojis 5 times bigger
int displayWidth = tft.width();
static int position[4] = {displayWidth, displayWidth, displayWidth, displayWidth};
for (int i = 0; i < 5; i++) {
// Display each enlarged emoji at a moving horizontal position
for (int y = 0; y < emojiHeight; y++) {
for (int x = 0; x < emojiWidth; x++) {
if (emojis[setIndex][i][y] & (1 << (emojiWidth - x - 1))) {
// Draw pixels for the enlarged emoji
for (int dy = 0; dy < scaleFactor; dy++) {
for (int dx = 0; dx < scaleFactor; dx++) {
tft.drawPixel(x * scaleFactor + position[setIndex] - i * (40 * scaleFactor) - dx, y * scaleFactor + dy, colors[setIndex]);
}
}
}
}
}
}
position[setIndex] -= speed;
if (position[setIndex] <= -40 * scaleFactor) {
position[setIndex] = displayWidth;
}
}