#include <LedControl.h>
// Create an instance of the LedControl library
// Parameters: DIN pin, CLK pin, CS pin, number of displays (1 for a single display)
LedControl lc = LedControl(A10, A9, A8, 4);
void setup()
{
// Initialize all displays
for (int i = 0; i < 4; i++) {
lc.shutdown(i, false); // Wake up the MAX7219
lc.setIntensity(i, 8); // Set brightness level (0 is min, 15 is max)
lc.clearDisplay(i); // Clear the display register
}
// Display the text "HELLO"
displayText("HELLO");
}
void displayText(String text) {
int offset = 0; // Offset to handle scrolling
for (int i = 0; i < text.length(); i++) {
// Clear previous character to avoid overlap
for (int j = 0; j < 4; j++) {
lc.clearDisplay(j);
}
// Display each character across the matrices
for (int j = 0; j < 4; j++) {
if (i + j < text.length()) {
lc.setChar(j, 7 - offset, text[i + j], false);
}
}
delay(200); // Delay for scrolling effect
offset++;
}
}
void loop()
{
// Empty loop since we're displaying in setup
}