#include <LedControl.h>
// Pin definitions for MAX7219
const int DIN_PIN = 11; // Data In (MOSI)
const int CS_PIN = 10; // Chip Select
const int CLK_PIN = 13; // Clock (SCK)
// Create a LedControl instance
LedControl lc = LedControl(DIN_PIN, CLK_PIN, CS_PIN, 1);
void setup() {
// Initialize the MAX7219
lc.shutdown(0, false); // Wake up the MAX7219 from power-saving mode
lc.setIntensity(0, 8); // Set brightness level (0 is min, 15 is max)
lc.clearDisplay(0); // Clear the display
}
void loop() {
// Example graphical test pattern
for (int row = 0; row < 8; row++) {
for (int col = 0; col < 8; col++) {
// Create a checkerboard pattern
if ((row + col) % 2 == 0) {
lc.setLed(0, row, col, true);
} else {
lc.setLed(0, row, col, false);
}
}
}
delay(1000); // Display the pattern for 1 second
// Clear the display
lc.clearDisplay(0);
delay(500); // Wait for 0.5 second
// Display a different pattern
for (int row = 0; row < 8; row++) {
for (int col = 0; col < 8; col++) {
// Create a diagonal pattern
if (row == col || row + col == 7) {
lc.setLed(0, row, col, true);
} else {
lc.setLed(0, row, col, false);
}
}
}
delay(1000); // Display the pattern for 1 second
// Clear the display
lc.clearDisplay(0);
delay(500); // Wait for 0.5 second
}