#include <SPI.h>
byte symbol[8] = {0x60, 0xF0, 0xF0, 0x7F, 0x07, 0x06, 0x0C, 0x08};
const byte NOOP = 0x0;
const byte DECODEMODE = 0x9;
const byte INTENSITY = 0xA;
const byte SCANLIMIT = 0xB;
const byte SHUTDOWN = 0xC;
const byte DISPLAYTEST = 0xF;
void setup() {
pinMode(10, OUTPUT);
digitalWrite(10, HIGH); // Set chip select high
SPI.begin();
// Initialize the MAX7219
max7219(SCANLIMIT, 7); // 8 digits
max7219(DECODEMODE, 0); // No decode for digits
max7219(INTENSITY, 8); // Set intensity (0-15)
max7219(DISPLAYTEST, 0); // Disable display test
max7219(SHUTDOWN, 1); // Wake up the MAX7219
// Clear the display
for (byte i = 0; i < 8; i++) {
max7219(i + 1, 0);
}
}
void loop() {
// Display each byte from the symbol array
for (byte i = 0; i < 8; i++) {
max7219(i + 1, symbol[i]);
}
delay(1000); // Delay to make the changes visible
}
void max7219(byte reg, byte data) {
digitalWrite(10, LOW); // Start communication
SPI.transfer(reg); // Send register address
SPI.transfer(data); // Send data
digitalWrite(10, HIGH); // End communication
}