const int ROW_DATA = 7;
const int ROW_CLK = 5;
const int COL_DATA = 4;
const int COL_CLK = 2;
const int DATA_LATCH = 3;
#define LED_ROW_CNT 8
#define LED_COL_CNT 8
#define ANIMATION_DELAY 80;
const unsigned char LED_DATA[LED_ROW_CNT][LED_COL_CNT] = {
/****************Outer Squares******************/
{0xff, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xff},
{0x00, 0x7e, 0x42, 0x42, 0x42, 0x42, 0x7e, 0x00},
{0x00, 0x00, 0x3c, 0x24, 0x24, 0x3c, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00},
/****************Outer Squares******************/
/*************Inner To Outer Squares************/
{0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x3c, 0x24, 0x24, 0x3c, 0x00, 0x00},
{0x00, 0x7e, 0x42, 0x42, 0x42, 0x42, 0x7e, 0x00},
{0xff, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xff},
/*************Inner To Outer Squares************/
};
const unsigned char LED_COL[LED_COL_CNT] = {0x7f, 0xbf, 0xdf, 0xef, 0xf7, 0xfb, 0xfd, 0xfe};
void Pulse(const int pinN)
{
digitalWrite(pinN, LOW);
delayMicroseconds(1);
digitalWrite(pinN, HIGH);
delayMicroseconds(1);
}
void setup() {
pinMode(ROW_DATA, OUTPUT);
pinMode(ROW_CLK, OUTPUT);
pinMode(COL_DATA, OUTPUT);
pinMode(COL_CLK, OUTPUT);
pinMode(DATA_LATCH, OUTPUT);
digitalWrite(ROW_DATA, HIGH);
digitalWrite(ROW_CLK, HIGH);
digitalWrite(COL_DATA, HIGH);
digitalWrite(COL_CLK, HIGH);
digitalWrite(DATA_LATCH, HIGH);
shiftOut(ROW_DATA, ROW_CLK, MSBFIRST, 0x00);
shiftOut(COL_DATA, COL_CLK, MSBFIRST, 0xff);
}
void loop() {
while(1)
{
for(int i = 0; i < LED_ROW_CNT; i++)
{
int s = ANIMATION_DELAY;
do{
for(int j = 0; j < LED_COL_CNT; j++)
{
shiftOut(ROW_DATA, ROW_CLK, LSBFIRST, LED_DATA[i][j]);
shiftOut(COL_DATA, COL_CLK, LSBFIRST, LED_COL[j]);
Pulse(DATA_LATCH);
}
s--;
}while(s > 0);
}
}
}