Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //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 matrixLEFT(void) {
- for (int i = 0; i < 8; i++) {
- lc.setRow(0, i, LEFT[i]);
- }
- }
- void matrixRIGHT(void) {
- for (int i = 0; i < 8; i++) {
- lc.setRow(0, i, RIGHT[i]);
- }
- }
- void matrixUP(void) {
- for (int i = 0; i < 8; i++) {
- lc.setRow(0, i, UP[i]);
- }
- }
- void matrixDIAMOND(void) {
- for (int i = 0; i < 8; i++) {
- lc.setRow(0, i, DIAMOND[i]);
- }
- }
- void matrixSQUARE(void) {
- for (int i = 0; i < 8; i++) {
- lc.setRow(0, i, SQUARE[i]);
- }
- }
- void matrixSQUARE1(void) {
- for (int i = 0; i < 8; i++) {
- lc.setRow(0, i, SQUARE1[i]);
- }
- }
- void matrixSQUARE2(void) {
- for (int i = 0; i < 8; i++) {
- lc.setRow(0, i, SQUARE2[i]);
- }
- }
- void matrixSQUARE3(void) {
- for (int i = 0; i < 8; i++) {
- lc.setRow(0, i, SQUARE3[i]);
- }
- }
- void loop() {
- matrixLEFT();
- delay(delaytime);
- matrixRIGHT();
- delay(delaytime);
- matrixUP();
- delay(delaytime);
- matrixDIAMOND();
- delay(delaytime);
- matrixSQUARE();
- delay(delaytime);
- matrixSQUARE1();
- delay(delaytime);
- matrixSQUARE2();
- delay(delaytime);
- matrixSQUARE3();
- lc.clearDisplay(0);
- delay(delaytime);
- }
Add Comment
Please, Sign In to add comment