#include "LedControl.h"
const int dinPin = 11;
const int csPin = 10;
const int clkPin = 13;
LedControl lc=LedControl(dinPin, clkPin, csPin,3);
// pin 11 is connected to the MAX7219 pin 1 (DIN)[Data in]
// pin 13 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 T { \
{0, 1, 1, 1, 1, 1, 1, 0}, \
{0, 1, 1, 1, 1, 1, 1, 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, 0, 1, 1, 0, 0, 0}, \
{0, 0, 0, 1, 1, 0, 0, 0} \
}
#define I { \
{0, 1, 1, 1, 1, 1, 1, 0}, \
{0, 1, 1, 1, 1, 1, 1, 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, 1, 1, 1, 1, 1, 1, 0}, \
{0, 1, 1, 1, 1, 1, 1, 0} \
}
#define M {\
{1, 1, 0, 0, 0, 0, 1, 1}, \
{1, 1, 1, 0, 0, 1, 1, 1}, \
{1, 1, 1, 0, 0, 1, 1, 1}, \
{1, 1, 1, 0, 0, 1, 1, 1}, \
{1, 1, 0, 1, 1, 0, 1, 1}, \
{1, 1, 0, 1, 1, 0, 1, 1}, \
{1, 1, 0, 0, 0, 0, 1, 1}, \
{1, 1, 0, 0, 0, 0, 1, 1} \
}
#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 T { \
{0, 1, 1, 1, 1, 1, 1, 0}, \
{0, 1, 1, 1, 1, 1, 1, 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, 0, 1, 1, 0, 0, 0}, \
{0, 0, 0, 1, 1, 0, 0, 0} \
}
#define H { \
{1, 1, 0, 0, 0, 0, 1, 1}, \
{1, 1, 0, 0, 0, 0, 1, 1}, \
{1, 1, 0, 0, 0, 0, 1, 1}, \
{1, 1, 1, 1, 1, 1, 1, 1}, \
{1, 1, 1, 1, 1, 1, 1, 1}, \
{1, 1, 0, 0, 0, 0, 1, 1}, \
{1, 1, 0, 0, 0, 0, 1, 1}, \
{1, 1, 0, 0, 0, 0, 1, 1} \
}
#define Y { \
{1, 1, 0, 0, 0, 0, 1, 1}, \
{0, 1, 1, 0, 0, 1, 1, 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, 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] = {
T,I,M,O,T,H,Y,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
// the zero refers to the MAX7219 number, it is zero for 1 chip
lc.shutdown(1,false);// turn off power saving, enables display
lc.setIntensity(1,8);// sets brightness (0~15 possible values)
lc.clearDisplay(1);// clear screen
// the zero refers to the MAX7219 number, it is zero for 1 chip
lc.shutdown(2,false);// turn off power saving, enables display
lc.setIntensity(2,8);// sets brightness (0~15 possible values)
lc.clearDisplay(2);// clear screen
}
void loop()
{
if(pattern>=numPatterns){
pattern = 0;
}
setPattern(pattern);
pattern++;
delay(1000);
}
void setPattern(int pattern) {
for (int k = 0; k <3; k++){
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if ((pattern - k)>= 0 && patterns[pattern-k][i][j] == 1) {
lc.setLed(k,i,7-j,true);
} else {
lc.setLed(k,i,7-j,false);
}
}
}
}
}