//We always have to include the library
#include "LedControl.h"
/*
Now we need a LedControl to work with.
***** These pin numbers will probably not work with your hardware *****
pin 12 is connected to the DataIn
pin 11 is connected to the CLK
pin 10 is connected to LOAD
We have only a single MAX72XX.
*/
LedControl lc = LedControl(12, 11, 10, 1);
byte LEFT[] = { B00011000, B00110000, B01100000, B11011111, B11011111, B01100000, B00110000, B00011000};
byte RIGHT[] = { B00011000, B00001100, B00000110, B11111011, B11111011, B00000110, B00001100, B00011000};
byte UP[] = { B00011000, B00111100, B01100110, B11011011, B10011001, B00011000, B00011000, B00011000};
byte DIAMOND[] = { B00011000, B00111100, B01111110, B11111111, B11111111, B01111110, B00111100, B00011000};
byte SQUARE[] = { B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111};
byte SQUARE1[] = { B00100100, B01000010, B10000001, B00000000, B00000000, B10000001, B01000010, B00100100};
byte SQUARE2[] = { B00000000, B00100100, B01100110, B00000000, B00000000, B01100110, B00100100, B00000000};
byte SQUARE3[] = { B00000000, B00000000, B00000000, B00011000, B00011000, B00000000, B00000000, B00000000};
/* we always wait a bit between updates of the display */
unsigned long delaytime = 1000;
void setup() {
/*
The MAX72XX is in power-saving mode on startup,
we have to do a wakeup call
*/
lc.shutdown(0, false);
/* Set the brightness to a medium values */
lc.setIntensity(0, 8);
/* and clear the display */
lc.clearDisplay(0);
}
void loop() {
lc.setRow(0, 0, LEFT[0]);
lc.setRow(0, 1, LEFT[1]);
lc.setRow(0, 2, LEFT[2]);
lc.setRow(0, 3, LEFT[3]);
lc.setRow(0, 4, LEFT[4]);
lc.setRow(0, 5, LEFT[5]);
lc.setRow(0, 6, LEFT[6]);
lc.setRow(0, 7, LEFT[7]);
delay(delaytime);
lc.setRow(0, 0, RIGHT[0]);
lc.setRow(0, 1, RIGHT[1]);
lc.setRow(0, 2, RIGHT[2]);
lc.setRow(0, 3, RIGHT[3]);
lc.setRow(0, 4, RIGHT[4]);
lc.setRow(0, 5, RIGHT[5]);
lc.setRow(0, 6, RIGHT[6]);
lc.setRow(0, 7, RIGHT[7]);
delay(delaytime);
lc.setRow(0, 0, UP[0]);
lc.setRow(0, 1, UP[1]);
lc.setRow(0, 2, UP[2]);
lc.setRow(0, 3, UP[3]);
lc.setRow(0, 4, UP[4]);
lc.setRow(0, 5, UP[5]);
lc.setRow(0, 6, UP[6]);
lc.setRow(0, 7, UP[7]);
delay(delaytime);
lc.setRow(0, 0, DIAMOND[0]);
lc.setRow(0, 1, DIAMOND[1]);
lc.setRow(0, 2, DIAMOND[2]);
lc.setRow(0, 3, DIAMOND[3]);
lc.setRow(0, 4, DIAMOND[4]);
lc.setRow(0, 5, DIAMOND[5]);
lc.setRow(0, 6, DIAMOND[6]);
lc.setRow(0, 7, DIAMOND[7]);
delay(delaytime);
lc.setRow(0, 0, SQUARE[0]);
lc.setRow(0, 1, SQUARE[1]);
lc.setRow(0, 2, SQUARE[2]);
lc.setRow(0, 3, SQUARE[3]);
lc.setRow(0, 4, SQUARE[4]);
lc.setRow(0, 5, SQUARE[5]);
lc.setRow(0, 6, SQUARE[6]);
lc.setRow(0, 7, SQUARE[7]);
delay(delaytime);
lc.setRow(0, 0, SQUARE1[0]);
lc.setRow(0, 1, SQUARE1[1]);
lc.setRow(0, 2, SQUARE1[2]);
lc.setRow(0, 3, SQUARE1[3]);
lc.setRow(0, 4, SQUARE1[4]);
lc.setRow(0, 5, SQUARE1[5]);
lc.setRow(0, 6, SQUARE1[6]);
lc.setRow(0, 7, SQUARE1[7]);
delay(delaytime);
lc.setRow(0, 0, SQUARE2[0]);
lc.setRow(0, 1, SQUARE2[1]);
lc.setRow(0, 2, SQUARE2[2]);
lc.setRow(0, 3, SQUARE2[3]);
lc.setRow(0, 4, SQUARE2[4]);
lc.setRow(0, 5, SQUARE2[5]);
lc.setRow(0, 6, SQUARE2[6]);
lc.setRow(0, 7, SQUARE2[7]);
delay(delaytime);
lc.setRow(0, 0, SQUARE3[0]);
lc.setRow(0, 1, SQUARE3[1]);
lc.setRow(0, 2, SQUARE3[2]);
lc.setRow(0, 3, SQUARE3[3]);
lc.setRow(0, 4, SQUARE3[4]);
lc.setRow(0, 5, SQUARE3[5]);
lc.setRow(0, 6, SQUARE3[6]);
lc.setRow(0, 7, SQUARE3[7]);
delay(delaytime);
lc.clearDisplay(0);
delay(delaytime);
}
Comments