#include "LedControl.h"
// Pin configuration for the MAX7219 driver
const int DIN_PIN = 11; // Data in
const int CS_PIN = 10; // Chip select
const int CLK_PIN = 13; // Clock
LedControl lc = LedControl(DIN_PIN, CLK_PIN, CS_PIN, 1);
void setup() {
// Initialize the MAX7219
lc.shutdown(0, false);
lc.setIntensity(0, 8);
lc.clearDisplay(0);
}
void scrollSmileyLeft(int delayTime) {
byte smiley[8] = {
B00111100,
B01000010,
B10100101,
B10000001,
B10100101,
B10011001,
B01000010,
B00111100
};
for (int col = 0; col <= 8; col++) {
for (int row = 0; row <= 8; row++) {
byte shiftedValue = (smiley[row] << col);
lc.setRow(0, row, shiftedValue);
}
delay(delayTime);
}
for (int col = 8; col >= 0; col--) {
for (int row = 8; row >= 0; row--) {
byte shiftedValue = (smiley[row] >> col);
lc.setRow(0, row, shiftedValue);
}
delay(delayTime);
}
}
void loop() {
scrollSmileyLeft(250);
}