#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 display = 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 scroll = display.width();
// char sometext[] = "Never gonna give you up.";
const char sometext[] PROGMEM = // single, flat array of char
"Never "
"Gonna "
"Give "
"You "
"Up ";
int k;
int scrollwidth = sizeof(sometext) * 6; // each character is 5 pixels plus one kern pixel
void setup() {
Serial.begin(115200);
display.begin(); // Initialize the display object
display.setTextWrap(false);
display.setBrightness(255);
display.setTextColor(display.Color(255, 255, 255)); // Set text color (white)
}
void loop() {
scrollText();
}
void scrollText() {
// Serial.println(scroll);
display.fillScreen(0); //Turn off all the LEDs
display.setCursor(scroll, 0); // start displaying Neopixels at the right edge
// display.print(sometext); // store Neopixel buffer
// display.write(pgm_read_byte(sometext + k)); // for PROGMEM
// display.write(pgm_read_byte(&sometext[k])); // for PROGMEM
display.write(pgm_read_byte(sometext)); // for PROGMEM
if ( --scroll < -scrollwidth ) { // width of sizeof(text) scrolls from 32 to -150
scroll = display.width(); // re-start at the right
}
display.show(); // display the Neopixel buffer
delay(delayMS);
// k++;
}