Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <FastLED.h>
- #include <FastLED_GFX.h>
- #include <FastLEDMatrix.h>
- #define DATA_PIN 12
- #define COLOR_ORDER GRB
- #define CHIPSET WS2812B
- #define MATRIX_WIDTH 32 // width of FastLED matrix
- #define MATRIX_HEIGHT 8 // height of matrix
- #define MATRIX_TYPE (MTX_MATRIX_BOTTOM + MTX_MATRIX_RIGHT + MTX_MATRIX_COLUMNS + MTX_MATRIX_ZIGZAG)
- cFastLEDSingleMatrix<MATRIX_WIDTH, MATRIX_HEIGHT, MATRIX_TYPE> matrix;
- const CRGB colors[] = {
- CRGB(255, 0, 0),
- CRGB(0, 255, 0),
- CRGB(0, 0, 255)
- };
- void setMatrixBrightness(uint8_t brightness) {
- for (int i = 0; i < matrix.Size(); ++i) {
- matrix[0][i].setRGB(matrix[0][i].r * brightness / 5, matrix[0][i].g * brightness / 5, matrix[0][i].b * brightness / 5);
- }
- }
- void setup() {
- // Initialize FastLED
- FastLED.addLeds<CHIPSET, DATA_PIN, COLOR_ORDER>(matrix[0], matrix.Size());
- // Set initial brightness
- setMatrixBrightness(4);
- // Clear the matrix
- FastLED.clear(true);
- // Configure matrix properties
- matrix.setTextWrap(false);
- setMatrixBrightness(5);
- matrix.setTextColor(colors[0]);
- }
- int x = matrix.width();
- int pass = 0;
- void loop() {
- matrix.fillScreen(0);
- matrix.setCursor(x, 0);
- matrix.print(F("If you can read this you're too close"));
- // Display the matrix
- FastLED.show();
- delay(50); // Adjust the delay for a comfortable scrolling speed
- // Decrement x to scroll text to the right
- --x;
- // Check if the text has moved beyond the left edge of the matrix
- if (x < -36 * 7) { // Adjusted for the longer text
- x = matrix.width();
- if (++pass >= 3) pass = 0;
- matrix.setTextColor(colors[pass]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment