#include <LedControl.h>
const int DIN_PIN = 11;
const int CLK_PIN = 13;
const int CS_PIN_START = 10;
// Define the number of modules in the chain
const int NUM_MODULES = 8;
// Create an array of LedControl objects for each module
LedControl displays[NUM_MODULES] = {
LedControl(DIN_PIN, CLK_PIN, CS_PIN_START),
LedControl(DIN_PIN, CLK_PIN, CS_PIN_START + 1),
LedControl(DIN_PIN, CLK_PIN, CS_PIN_START + 2),
LedControl(DIN_PIN, CLK_PIN, CS_PIN_START + 3),
LedControl(DIN_PIN, CLK_PIN, CS_PIN_START + 4),
LedControl(DIN_PIN, CLK_PIN, CS_PIN_START + 5),
LedControl(DIN_PIN, CLK_PIN, CS_PIN_START + 6),
LedControl(DIN_PIN, CLK_PIN, CS_PIN_START + 7)
};
// Function to initialize all modules
void initializeModules() {
for (int i = 0; i < NUM_MODULES; i++) {
displays[i].shutdown(0, false);
displays[i].setIntensity(0, 10);
displays[i].clearDisplay(0);
}
}
// Function to display a pattern on all modules
void displayPatternOnAllModules(uint64_t pattern) {
for (int i = 0; i < NUM_MODULES; i++) {
for (int j = 0; j < 8; j++) {
displays[i].setRow(0, j, pattern >> (j * 8));
}
}
}
void setup() {
initializeModules();
}
void loop() {
// Display pattern on all modules
displayPatternOnAllModules(0x81); // Example pattern, adjust as needed
delay(1000); // Delay for visibility
}