#include "LedControl.h"
LedControl lc=LedControl(12,11,10,1);
// pin 12 is connected to the MAX7219 pin 1 (DIN)[Data in]
// pin 11 is connected to the CLK pin 13 (CLK)[clock]
// pin 10 is connected to LOAD pin 12 (CS)
// 1 as we are only using 1 MAX7219
#define A { \
{0, 0, 0, 1, 1, 0, 0, 0}, \
{0, 0, 1, 1, 1, 1, 0, 0}, \
{0, 1, 1, 0, 0, 1, 1, 0}, \
{0, 1, 1, 0, 0, 1, 1, 0}, \
{0, 1, 1, 1, 1, 1, 1, 0}, \
{0, 1, 1, 1, 1, 1, 1, 0}, \
{0, 1, 1, 0, 0, 1, 1, 0}, \
{0, 1, 1, 0, 0, 1, 1, 0} \
}
#define R { \
{0, 1, 1, 1, 1, 1, 0, 0}, \
{0, 1, 1, 1, 1, 1, 1, 0}, \
{0, 1, 1, 0, 0, 1, 1, 0}, \
{0, 1, 1, 0, 0, 1, 1, 0}, \
{0, 1, 1, 1, 1, 1, 0, 0}, \
{0, 1, 1, 1, 1, 1, 1, 0}, \
{0, 1, 1, 0, 0, 1, 1, 0}, \
{0, 1, 1, 0, 0, 1, 1, 0} \
}
#define D { \
{0, 1, 1, 1, 1, 1, 0, 0}, \
{0, 1, 1, 1, 1, 1, 1, 0}, \
{0, 1, 1, 0, 0, 1, 1, 0}, \
{0, 1, 1, 0, 0, 1, 1, 0}, \
{0, 1, 1, 0, 0, 1, 1, 0}, \
{0, 1, 1, 0, 0, 1, 1, 0}, \
{0, 1, 1, 1, 1, 1, 1, 0}, \
{0, 1, 1, 1, 1, 1, 0, 0} \
}
#define U { \
{0, 1, 1, 0, 0, 1, 1, 0}, \
{0, 1, 1, 0, 0, 1, 1, 0}, \
{0, 1, 1, 0, 0, 1, 1, 0}, \
{0, 1, 1, 0, 0, 1, 1, 0}, \
{0, 1, 1, 0, 0, 1, 1, 0}, \
{0, 1, 1, 0, 0, 1, 1, 0}, \
{0, 1, 1, 1, 1, 1, 1, 0}, \
{0, 0, 1, 1, 1, 1, 0, 0} \
}
#define I { \
{0, 0, 1, 1, 1, 1, 0, 0}, \
{0, 0, 1, 1, 1, 1, 0, 0}, \
{0, 0, 0, 1, 1, 0, 0, 0}, \
{0, 0, 0, 1, 1, 0, 0, 0}, \
{0, 0, 0, 1, 1, 0, 0, 0}, \
{0, 0, 0, 1, 1, 0, 0, 0}, \
{0, 0, 1, 1, 1, 1, 0, 0}, \
{0, 0, 1, 1, 1, 1, 0, 0} \
}
#define N { \
{0, 1, 1, 0, 0, 1, 1, 0}, \
{0, 1, 1, 1, 0, 1, 1, 0}, \
{0, 1, 1, 1, 0, 1, 1, 0}, \
{0, 1, 1, 1, 0, 1, 1, 0}, \
{0, 1, 1, 0, 1, 1, 1, 0}, \
{0, 1, 1, 0, 1, 1, 1, 0}, \
{0, 1, 1, 0, 1, 1, 1, 0}, \
{0, 1, 1, 0, 0, 1, 1, 0} \
}
#define O { \
{0, 0, 0, 1, 1, 0, 0, 0}, \
{0, 0, 1, 1, 1, 1, 0, 0}, \
{0, 1, 1, 0, 0, 1, 1, 0}, \
{0, 1, 1, 0, 0, 1, 1, 0}, \
{0, 1, 1, 0, 0, 1, 1, 0}, \
{0, 1, 1, 0, 0, 1, 1, 0}, \
{0, 0, 1, 1, 1, 1, 0, 0}, \
{0, 0, 0, 1, 1, 0, 0, 0} \
}
#define SPACE { \
{0, 0, 0, 0, 0, 0, 0, 0}, \
{0, 0, 0, 0, 0, 0, 0, 0}, \
{0, 0, 0, 0, 0, 0, 0, 0}, \
{0, 0, 0, 0, 0, 0, 0, 0}, \
{0, 0, 0, 0, 0, 0, 0, 0}, \
{0, 0, 0, 0, 0, 0, 0, 0}, \
{0, 0, 0, 0, 0, 0, 0, 0}, \
{0, 0, 0, 0, 0, 0, 0, 0} \
}
const int numPatterns = 8;
byte patterns[numPatterns][8][8] = {
A,R,D,U,I,N,O,SPACE
};
int pattern = 0;
void setup()
{
// the zero refers to the MAX7219 number, it is zero for 1 chip
lc.shutdown(0,false);// turn off power saving, enables display
lc.setIntensity(0,8);// sets brightness (0~15 possible values)
lc.clearDisplay(0);// clear screen
}
void loop()
{
if(pattern>=numPatterns){
pattern = 0;
}
setPattern(pattern);
pattern++;
delay(1000);
}
void setPattern(int pattern) {
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if (patterns[pattern][i][j] == 1) {
lc.setLed(0,i,j,true);
} else {
lc.setLed(0,i,j,false);
}
}
}
}