#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
//Things can be adjusted
#define duration 15 //duration message should scroll for in seconds e.g 240=4minute
#define brightness 200 //keep between --255
int counter = -1; //keep count of which message to be displayed
#define NumMessages 10
String message[NumMessages] = {
"Have a lovely Day",
"Mothers Day",
"Good Morning",
"Best of Luck",
"Keep it simple",
"Never give up",
"Give it your best",
"Let it be",
"You are the Best!"
};
const int textSize = 2; // Adjust text size here (1 = smallest, increase for larger text)
const int scrollSpeed = 20000; // Adjust scroll speed here (lower value = faster scrolling)
#define NEO_PIN 5
#define NEO_WIDTH 32
#define NEO_HEIGHT 16
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(NEO_WIDTH, NEO_HEIGHT, NEO_PIN,
NEO_MATRIX_TOP + NEO_MATRIX_LEFT +
NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG,
NEO_GRB + NEO_KHZ800);
const uint16_t colors[] = {matrix.Color(255, 0, 0), matrix.Color(120, 150, 0), matrix.Color(0, 0, 255), matrix.Color(195, 180, 90), matrix.Color(40, 80, 70), matrix.Color(220, 210, 120), matrix.Color(150, 200, 220)};
long int timer = 0;
bool flag = false;
int c = 0;
void setup() {
Serial.begin(115200);
pinMode(23, INPUT_PULLUP);
matrix.begin();
matrix.setTextWrap(false);
matrix.setBrightness(brightness); // Set brightness level, adjust if necessary
matrix.setTextSize(textSize); // Set text size
}
void mover()
{
int i = random(10);
while (i == counter)
i = random(10);
counter = i;
flag = true;
c = 0;
delay(100);
}
void loop() {
int16_t textHeight = matrix.height() * textSize; // Calculate adjusted text height
int16_t yPos = 0; // Center vertically
if (flag) {
timer = millis();
long current = millis();
c = 0;
while (c < duration)
{
int choice = counter;
int16_t textWidth = message[choice].length(); // Calculate adjusted text width
textWidth = textWidth * 12;
for (int16_t x = matrix.width(); x >= -textWidth; x--) {
if (timer < (current - 1000))
{
c++;
timer = current;
}
current = millis();
Serial.println(c);
if (digitalRead(23) == LOW)
mover();
matrix.fillScreen(0); // Clear the matrix
matrix.setTextColor(colors[random(7)]);
matrix.setCursor(x, yPos);
matrix.print(message[choice]);
matrix.show();
delayMicroseconds(scrollSpeed); // Adjust scrolling speed here
}
}
flag = false;
}
if (digitalRead(23) == LOW)
mover();
}