#include "LedControl.h"
// Pins for the MAX7219
#define DIN_PIN 5 // Data In
#define CS_PIN 6 // Chip Select
#define CLK_PIN 7 // Clock
byte LEDCounts = 64;
byte delaytime = 100;
LedControl lc = LedControl(DIN_PIN, CLK_PIN, CS_PIN, 1);
void setup() {
//pinMode(A0,INPUT);
//pinMode(A1,INPUT);
lc.shutdown(0, false); // Wake up MAX7219
lc.shutdown(1, false);
lc.setIntensity(0, 8); // Set brightness (0-15)
lc.clearDisplay(0); // Clear the display
}
void loop() {
effect_01();
effect_02();
effect_03();
effect_04();
effect_05();
effect_06();
for (int k=0; k<6;k++) {effect_07();}
for (int k=0; k<6;k++) {effect_08();}
effect_09();
effect_01();
effect_10();
effect_11();
effect_12();
}
void effect_01() { // Light effect #1
lc.clearDisplay(0);
for (int i = 0; i < LEDCounts/2; i++) {
int row = i / 8; // Calculate the row index
int col = i % 8; // Calculate the column index
int j = (LEDCounts-1-i);
int row1 = j / 8; // Calculate the row index
int col1 = j % 8; // Calculate the column index
lc.setLed(0,row,col,1); //i
lc.setLed(0,row1,col1,1); //j
delay(delaytime);
}
}
//-------------------------------------------------------------------------
void effect_02() { // Light effect #2
lc.clearDisplay(0);
for (int i = LEDCounts/2; i >= 0; i--) {
int row = i / 8; // Calculate the row index
int col = i % 8; // Calculate the column index
int j = (LEDCounts-1-i);
int row1 = j / 8; // Calculate the row index
int col1 = j % 8; // Calculate the column index
lc.setLed(0,row,col,1); //i
lc.setLed(0,row1,col1,1); //j
delay(delaytime);
}
}
//-------------------------------------------------------------------------
void effect_03() { // Light effect #3
lc.clearDisplay(0);
for (int i = 0; i < LEDCounts/2; i++) {
int row = i / 8; // Calculate the row index
int col = i % 8; // Calculate the column index
int j = (LEDCounts-1-i);
int row1 = j / 8; // Calculate the row index
int col1 = j % 8; // Calculate the column index
lc.setLed(0,row,col,1); //i
lc.setLed(0,row1,col1,1); //j
delay(delaytime);
lc.clearDisplay(0);
}
}
//-------------------------------------------------------------------------
void effect_04() { // Light effect #4
lc.clearDisplay(0);
for (int i = LEDCounts/2; i >= 0; i--) {
int row = i / 8; // Calculate the row index
int col = i % 8; // Calculate the column index
int j = (LEDCounts-1-i);
int row1 = j / 8; // Calculate the row index
int col1 = j % 8; // Calculate the column index
lc.setLed(0,row,col,1); //i
lc.setLed(0,row1,col1,1); //j
delay(delaytime);
lc.clearDisplay(0);
}
}
//-------------------------------------------------------------------------
void effect_05() { // Light effect #5
lc.clearDisplay(0);
for (int i = 0; i < LEDCounts-3; i++) {
int row = i / 8; // Calculate the row index
int col = i % 8; // Calculate the column index
int j = i+1;
int f =i+2;
int row1 = j / 8; // Calculate the row index
int col1 = j % 8; // Calculate the column index
int row2 = f / 8; // Calculate the row index
int col2 = f % 8; // Calculate the column index
lc.setLed(0,row,col,1); //i
lc.setLed(0,row1,col1,1); //j
lc.setLed(0,row2,col2,1); //f
delay(delaytime);
lc.clearDisplay(0);
}
}
//-------------------------------------------------------------------------
void effect_06() { // Light effect #6
lc.clearDisplay(0);
for (int i = LEDCounts-3; i >=0; i--) {
int row = i / 8; // Calculate the row index
int col = i % 8; // Calculate the column index
int j = i+1;
int f =i+2;
int row1 = j / 8; // Calculate the row index
int col1 = j % 8; // Calculate the column index
int row2 = f / 8; // Calculate the row index
int col2 = f % 8; // Calculate the column index
lc.setLed(0,row,col,1); //i
lc.setLed(0,row1,col1,1); //j
lc.setLed(0,row2,col2,1); //f
delay(delaytime);
lc.clearDisplay(0);
}
}
//-------------------------------------------------------------------------
void effect_07() { // Light effect #7 paire/impaire 1
lc.clearDisplay(0);
for (int i = 0; i < LEDCounts; i+=2) {
int row = i / 8; // Calculate the row index
int col = i % 8; // Calculate the column index
lc.setLed(0,row,col,1); //i
}
delay(delaytime);
lc.clearDisplay(0);
for (int i = 1; i < LEDCounts; i+=2) {
int row = i / 8; // Calculate the row index
int col = i % 8; // Calculate the column index
lc.setLed(0,row,col,1); //i
}
delay(delaytime);
}
//-------------------------------------------------------------------------
void effect_08() { // Light effect #8 paire/impaire 2
lc.clearDisplay(0);
for (int i = 0; i < LEDCounts; i+=3) {
int row = i / 8; // Calculate the row index
int col = i % 8; // Calculate the column index
lc.setLed(0,row,col,1); //i
}
delay(delaytime);
lc.clearDisplay(0);
for (int i = 1; i < LEDCounts; i+=3) {
int row = i / 8; // Calculate the row index
int col = i % 8; // Calculate the column index
lc.setLed(0,row,col,1); //i
}
delay(delaytime);
lc.clearDisplay(0);
for (int i = 2; i < LEDCounts; i+=3) {
int row = i / 8; // Calculate the row index
int col = i % 8; // Calculate the column index
lc.setLed(0,row,col,1); //i
}
delay(delaytime);
}
void effect_09() { // Light effect #9
lc.clearDisplay(0);
for (int i =0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
lc.setLed(0,i,j,1);
delay(delaytime);
}
lc.clearDisplay(0);
}
for (int i = 3; i >= 0; i--) {
for (int j = 8; j >=0; j--) {
lc.setLed(0,i,j,1);
delay(delaytime);
}
lc.clearDisplay(0);
}
}
void effect_10() { // Light effect #10
lc.clearDisplay(0);
for (int i =0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
lc.setLed(0,i,j,1);
}
delay(delaytime);
lc.clearDisplay(0);
}
for (int i = 3; i >= 0; i--) {
for (int j = 8; j >=0; j--) {
lc.setLed(0,i,j,1);
}
delay(delaytime);
lc.clearDisplay(0);
}
}
void effect_11() { // Light effect #11
lc.clearDisplay(0);
for (int i = 0; i < LEDCounts/2; i++) {
int row = i / 8; // Calculate the row index
int col = i % 8; // Calculate the column index
int j = (LEDCounts-1-i);
int row1 = j / 8; // Calculate the row index
int col1 = j % 8; // Calculate the column index
lc.setLed(0,row,col,1); //i
lc.setLed(0,row1,col1,1); //j
delay(delaytime);
}
for (int i = 0; i < LEDCounts/2; i++) {
int row = i / 8; // Calculate the row index
int col = i % 8; // Calculate the column index
int j = (LEDCounts-1-i);
int row1 = j / 8; // Calculate the row index
int col1 = j % 8; // Calculate the column index
lc.setLed(0,row,col,0); //i
lc.setLed(0,row1,col1,0); //j
delay(delaytime);
}
}
void effect_12() { // Light effect #12
lc.clearDisplay(0);
for (int i = 0; i < LEDCounts/2; i++) {
int row = i / 8; // Calculate the row index
int col = i % 8; // Calculate the column index
int j = (LEDCounts-1-i);
int row1 = j / 8; // Calculate the row index
int col1 = j % 8; // Calculate the column index
lc.setLed(0,row,col,1); //i
lc.setLed(0,row1,col1,1); //j
delay(delaytime);
}
for (int i = LEDCounts/2; i >=0; i--) {
int row = i / 8; // Calculate the row index
int col = i % 8; // Calculate the column index
int j = (LEDCounts-i+1);
int row1 = j / 8; // Calculate the row index
int col1 = j % 8; // Calculate the column index
lc.setLed(0,row,col,0); //i
lc.setLed(0,row1,col1,0); //j
delay(delaytime);
}
}