//http://robojax.com/learn/arduino/8x8LED/
//http://xantorohara.github.io/led-matrix-editor/#3810101010101810
//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 SQUARE0[] = { 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};
byte CIRCLE0[] = { B00000000, B00000000, B00000000, B00011000, B00011000, B00000000, B00000000, B00000000};
byte CIRCLE1[] = { B00000000, B00000000, B00011000, B00100100, B00100100, B00011000, B00000000, B00000000};
byte CIRCLE2[] = { B00000000, B00111100, B01000010, B01000010, B01000010, B01000010, B00111100, B00000000};
byte CIRCLE3[] = { B01111110, B10000001, B10000001, B10000001, B10000001, B10000001, B10000001, B01111110};
byte VAR1[] = { B10000000, B10000000, B10000000, B10000000, B10000000, B10000000, B10000000, B10000000};
byte TEMP[8] ;
/* 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 matrix(byte PARAM[]) {
for (int i = 0; i < 8; i++) {
lc.setRow(0, i, PARAM[i]);
}
}
void matrixShiftRIGHT(void) {
//SHift to left
memcpy(TEMP, RIGHT, 8); // or strcpy( TEMP, RIGHT);
for (int j = 8; j >= 0; j--) {
for (int i = 0; i < 8; i++) {
TEMP[i] = TEMP[i] << j;
}
matrix(TEMP);
delay(delaytime);
memcpy(TEMP, RIGHT, 8);
}
for (int j = 1; j < 8; j++) {
for (int i = 0; i < 8; i++) {
TEMP[i] = TEMP[i] >> j;
}
matrix(TEMP);
delay(delaytime);
memcpy(TEMP, RIGHT, 8);
}
}
void matrixShiftLEFT(void) {
//SHift to left
for (int j = 0; j <= 8; j++) {
for (int i = 0; i < 8; i++) {
TEMP[i] = TEMP[i] << j;
}
matrix(TEMP);
delay(delaytime);
memcpy(TEMP, LEFT, 8);
}
// memcpy(TEMP, LEFT, 8);
// for (int j = 1; j < 8; j++) {
// for (int i = 0; i < 8; i++) {
// TEMP[i] = TEMP[i] >> j;
// }
// matrix(TEMP);
// delay(delaytime);
// memcpy(TEMP, LEFT, 8);
// }
}
void loop() {
matrixShiftLEFT();
// matrix(LEFT);
// delay(delaytime);
// matrix(RIGHT);
// delay(delaytime);
// matrix(UP);
// delay(delaytime);
// matrix(DIAMOND);
// delay(delaytime);
// matrix(SQUARE);
// delay(delaytime);
// matrix(SQUARE1);
// delay(delaytime);
// matrix(SQUARE2);
// delay(delaytime);
// matrix(SQUARE3);
// delay(delaytime);
// matrix(CIRCLE0);
// delay(delaytime);
// matrix(CIRCLE1);
// delay(delaytime);
// matrix(CIRCLE2);
// delay(delaytime);
// matrix(CIRCLE3);
// delay(delaytime);
// for (int i = 0; i < 4; i++) {
// matrix(CIRCLE3);
// delay(delaytime);
// matrix(CIRCLE2);
// delay(delaytime);
// matrix(CIRCLE1);
// delay(delaytime);
// }
// lc.clearDisplay(0);
// delay(100);
}
Comments