#include #include #include // Optional: Use any font from Adafruit_GFX #define DATA_PIN D2 // Data pin for the matrix #define NUM_LEDS 256 // Total LEDs (8 rows x 32 columns) #define LED_TYPE WS2812 // LED type #define COLOR_ORDER GRB // Color order CRGB leds[NUM_LEDS]; // Array to store the LED colors Adafruit_GFX *gfx; // Pointer to the graphics object int textX = 32; // Starting X position for scrolling text void setup() { FastLED.addLeds(leds, NUM_LEDS); // Set up FastLED FastLED.setBrightness(50); // Set brightness level (0-255) gfx = new Adafruit_GFX(32, 8); // Initialize the graphics object for a 32x8 matrix // Initialize the matrix (clear it first) fill_solid(leds, NUM_LEDS, CRGB::Black); FastLED.show(); } void loop() { // Message to scroll String message = "Hello World! "; // Scroll the message across the screen for (int x = textX; x >= -message.length() * 6; x--) { // Clear the previous frame fill_solid(leds, NUM_LEDS, CRGB::Black); // Draw the text at the current position (x) gfx->setCursor(x, 0); gfx->setTextColor(CRGB::White); // Set text color gfx->setTextSize(1); // Set text size gfx->print(message); // Print the message // Copy the graphics buffer to the LED array drawMatrixToLEDs(); // Show the updated LEDs FastLED.show(); delay(100); // Adjust the speed of the scroll } // Reset the starting point for the scroll after it goes off-screen textX = 32; } // Function to copy the Adafruit_GFX buffer to the LED array void drawMatrixToLEDs() { for (int i = 0; i < 32; i++) { for (int j = 0; j < 8; j++) { int pixelColor = gfx->getTextColor(); // Get the color of the pixel (white or black) leds[j + i * 8] = (pixelColor == CRGB::White) ? CRGB::White : CRGB::Black; } } }