#include <Adafruit_GFX.h>
//#include <Font5x3.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
// DATA PIN
// If you want to use a different data pin on your microcontroller CHANGE THIS!
#define DATA_PIN 4
#define arr_len( x ) ( sizeof( x ) / sizeof( *x ) )
// Matrix setup params
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(8, 8,8,1, DATA_PIN,
NEO_TILE_TOP + NEO_TILE_RIGHT + NEO_TILE_COLUMNS + NEO_TILE_PROGRESSIVE +
NEO_MATRIX_BOTTOM + NEO_MATRIX_RIGHT + NEO_MATRIX_COLUMNS + NEO_MATRIX_ZIGZAG,
NEO_GRB + NEO_KHZ800);
// Edit this
// The important stuff, your message and colors
char* Text[]= {"Oier Imaz Ormazabal","Iraia Imaz Ormazabal","Luka Ormazabal Larranaga","EGILEA: Joxemari Ormazabal Ormazabal"};
const uint16_t colors[] = {
matrix.Color(255, 0, 255), matrix.Color(100, 255, 0), matrix.Color(255, 255, 0),matrix.Color(255,255, 255), matrix.Color(255, 0, 255), matrix.Color(0, 255, 255), matrix.Color(255, 255, 255)};
int brightness =255;
// End Edit
int numMode = arr_len(Text)-1;
int numColor = arr_len(colors)-1;
int pixelPerChar = 6;
int maxDisplacement;
int mode = 0;
void setup() {
matrix.begin();
matrix.setTextWrap(true);
matrix.setBrightness(brightness);
matrix.setTextColor(colors[0]);
Serial.begin(115200);
}
int y = matrix.height();
int x = matrix.width();
int pass = 0;
int line_pass = 0;
void loop() {
// if mode greater than numMode reset
if (mode > numMode) { mode = 0; }
matrix.fillScreen(0);
matrix.setCursor(x, 0);
matrix.setTextSize(1);
scroll(Text[mode],(analogRead(2)));
Serial.println(analogRead(2));
}
// this does the magic of scrolling
void scroll(char* message,int delays) {
maxDisplacement = strlen(message) * pixelPerChar;// + matrix.width();
if(++line_pass > matrix.width()) line_pass = 0;
matrix.setTextColor(colors[random(0,7)]);
//matrix.print(String(message[0]));
matrix.setTextColor(colors[random(0,7)]);
matrix.print(String(message));
if(--x < -maxDisplacement) {
x = matrix.width();
if(++pass >= numColor) { pass = 0; };
// matrix.setTextColor(colors[pass]);
mode++;
}
matrix.show();
delay(delays);
}