#include <Adafruit_NeoMatrix.h> // https://github.com/adafruit/Adafruit_NeoMatrix
// offload arrays from RAM to PROGMEM
// #include <avr/pgmspace.h> // https://github.com/Synapseware/avr/blob/master/include/avr/pgmspace.h
#define LED_PIN 6 // Data pin
#define DISPLAY_WIDTH 56 // 64 is too much for Uno/Nano
#define DISPLAY_HEIGHT 8
#define BRIGHTNESS 255
byte delayMS = 20;
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix (
DISPLAY_WIDTH, DISPLAY_HEIGHT, LED_PIN,
NEO_MATRIX_TOP + // NEO_MATRIX_BOTTOM
NEO_MATRIX_LEFT + // NEO_MATRIX_RIGHT
NEO_MATRIX_ROWS + // NEO_MATRIX_COLUMNS
NEO_MATRIX_PROGRESSIVE, // NEO_MATRIX_ZIGZAG,
NEO_GRB + // NEO_RGB
NEO_KHZ800 // NEO_KHZ400
);
int scrollWidth = matrix.width();
const uint16_t colors[] = {
matrix.Color(255, 0, 0), // red
matrix.Color(255, 255, 255), // wht
matrix.Color( 0, 0, 255) // blu
};
// char sometext[] = "Never gonna give you up."; // use with matrix.print(sometext);
const char sometext[] PROGMEM = {"Never Gonna Give You Up"}; // 144 pixels
int textlength = sizeof(sometext);
int scrolloff = textlength * 6; // each character is 5 pixels plus one kern pixel
void setup() {
// Serial.begin(115200);
matrix.begin(); // Initialize the display object
matrix.setTextWrap(false);
matrix.setBrightness(BRIGHTNESS);
matrix.setTextColor(colors[1]); // white
}
void loop() {
scrollText();
}
void scrollText() {
matrix.fillScreen(0); //Turn off all the LEDs
matrix.setCursor(scroll, 0); // start displaying Neopixels at the right edge
// matrix.print(sometext); // use with array of characters - no loop needed
for (int i = 0; i < textlength; i++) { // read all characters...
matrix.write(pgm_read_byte(sometext + i)); // ...from PROGMEM into buffer
}
if ( --scrollWidth < -scrolloff ) { // count from (size of matrix) to (negative)textlength
scrollWidth = matrix.width(); // re-start at the right
}
matrix.show(); // display the buffer
// delay(delayMS);
}