#include <LedControl.h>
// Define the number of MAX7219 modules and the pins they are connected to
#define NUM_MAX7219 4 // Assuming a 32x8 matrix requires 4 MAX7219 modules
#define DIN_PIN 12
#define CS_PIN 11
#define CLK_PIN 10
// Create a LedControl object
LedControl lc = LedControl(DIN_PIN, CLK_PIN, CS_PIN, NUM_MAX7219);
void setup() {
// Initialize the MAX7219 modules
for (int i = 0; i < NUM_MAX7219; i++) {
lc.shutdown(i, false);
lc.setIntensity(i, 8);
lc.clearDisplay(i);
}
// Display the scrolling message
scrollText("Hello, Welcome!", 100);
}
void loop() {
// Your main program loop can go here
}
void scrollText(const char* text, int speed) {
int textLength = strlen(text);
// Add spaces to the end of the message for smooth scrolling
char scrollText[2 * textLength + 1];
strcpy(scrollText, text);
strcat(scrollText, " "); // Add spaces for scrolling
// Scroll the text
for (int i = 0; i < 8 * textLength; i++) {
for (int j = 0; j < NUM_MAX7219; j++) {
lc.setColumn(j, 7 - i % 8, fontLookup(scrollText[i / 8 + j * 4]) << (i % 8));
}
delay(speed);
}
}
byte fontLookup(char character) {
// Custom font lookup function for the characters you want to display
// Add more characters as needed
switch (character) {
case 'H':
return B10001000;
case 'e':
return B01111000;
case 'l':
return B00001000;
case 'o':
return B01111000;
case ',':
return B00000000; // Add more characters as needed
case ' ':
return B00000000; // Space character
default:
return B00000000; // Default to space for unknown characters
}
}