does anyone know how to make a random array display on a led matrix for an indefinite duration using the ledcontrol.h library? i can now only do it for a certain duration and then it changes to another random array.
here is the code i have:
#include <LedControl.h>
int DIN = 12;
int CS = 10;
int CLK = 11;
int Tx[4] = {2,3,3,4};
int Ty[4] = {0,0,1,0};
int Ix[4] = {2,3,4,5};
int Iy[4] = {0,0,0,0};
int Lx[4] = {2,3,4,4};
int Ly[4] = {0,0,0,1};
int Jx[4] = {2,2,3,4};
int Jy[4] = {1,0,0,0};
int Zx[4] = {2,3,3,4};
int Zy[4] = {1,1,0,0};
int Sx[4] = {2,3,3,4};
int Sy[4] = {0,0,1,1};
int Ox[4] = {3,4,3,4};
int Oy[4] = {0,0,1,1};
int x[4];
int y[4];
LedControl lc=LedControl(DIN, CLK, CS,2);
void setup() {
// put your setup code here, to run once:
for(int i=0;i<2;i++){
lc.shutdown(i,false);
lc.setIntensity(i,8);
lc.clearDisplay(i);
}
randomSeed(analogRead(0));
}
void loop() {
// put your main code here, to run repeatedly:
block();
for(int i = 0; i < 4; i++) {
lc.setLed(0, y[i], x[i], true);
};
delay(1000);
for(int i = 0; i < 4; i++) {
lc.setLed(0, y[i], x[i], false);
};
delay(1000);
}
void block() {
long block = random(1,8);
if(block == 1) {
memcpy(x, Tx, 8);
memcpy(y, Ty, 8);
} else if(long== 2) {
memcpy(x, Ix, 8);
memcpy(y, Iy, 8);
} else if(long== 3) {
memcpy(x, Lx, 8);
memcpy(y, Ly, 8);
} else if(long== 4) {
memcpy(x, Jx, 8);
memcpy(y, Jy, 8);
} else if(long== 5) {
memcpy(x, Zx, 8);
memcpy(y, Zy, 8);
} else if(long== 6) {
memcpy(x, Sx, 8);
memcpy(y, Sy, 8);
} else if(long== 7) {
memcpy(x, Ox, 8);
memcpy(y, Oy, 8);
}
}