#include <MD_MAX72xx.h>
#define down_ 1
#define up_ 2
#define MAX_DEVICES 2
#define start_1 0
#define END 2
#define task 0
const int maxX = MAX_DEVICES * 8 - 1;
const int maxY = 7;
#define CLK_PIN 13
#define DATA_PIN 11
#define CS_PIN 10
#define VERT_PIN A0
#define HORZ_PIN A1
#define SEL_PIN 2
MD_MAX72XX mx = MD_MAX72XX(MD_MAX72XX::PAROLA_HW, CS_PIN, MAX_DEVICES);
void up(){
int i = 8;
int k = 0;
int row = 8;
int col_1 = 0 ;
int col_2 = 0 ;
int f =0 ;
while(f<64){
f++;
Serial.println(k + row);
mx.setPoint(col_1++, k + row, 1);
if(col_1 >7){
col_1 =0;
k++;
}
mx.setPoint(col_2++, i - row, 0);
Serial.println( i - row);
if(col_2 >7){
col_2 =0;
i++;
}
if(i > 15){
i=15;
k = 7;
}
delay(10);
}
}
void down(){
signed int i = 7;
signed int k = 15;
int row = 8;
int col_1 = 0 ;
int col_2 = 0 ;
int f =0 ;
while(f<64){
f++;
if( i <0){
i=0 ;
k = 8 ;
}
mx.setPoint(col_1++, k , 0);
mx.setPoint(col_2++, i , 1);
if(col_2 >7){
col_2 =0;
i--;
}
if(col_1 >7){
col_1 =0;
k--;
}
delay(10);
}
}
void start(){
int x = 0;
int y = 0;
while(x<8){
while(y<8){
mx.setPoint(y, x, 1);
y++;
}
y=0;
x++;
if(x >7){
return;
}
//mx.update();
}
}
void setup() {
Serial.begin(115200);
mx.begin();
mx.control(MD_MAX72XX::INTENSITY, MAX_INTENSITY / 2);
mx.clear();
pinMode(VERT_PIN, INPUT);
pinMode(HORZ_PIN, INPUT);
pinMode(SEL_PIN, INPUT_PULLUP);
start(); //دالة البداية
}
void loop()
switch(task){ ;
case start_1 :
start();
task=up_ ;
break;
case up_ :
up();
task=END ;
case down_ :
down();
task=END ;
break
}