I build a LED cube and now I have to program it.
Currently, the issue is that when I want to use a 2 dimension array, it just skips the other 3 and always shows me the first one of the array.
That is what shows the Serial Monitor:
0
0
0
0
0
0
1
1
1
1
1
1
2
2
2
2
2
2
3
3
3
3
3
3
0
0
0
0
0
0
1
1
1
1
1
1
2
2
2
2
2
2
3
3
3
3
3
3
0
0
0
0
0
0
Schematic:
Layout:
Cube:
Code:
const int DATA_PIN = 4;
const int CLOCK_PIN = 3;
const int LATCH_PIN = 2;
const int LAYER_1 = 8;
const int LAYER_2 = 9;
const int LAYER_3 = 10;
const int LAYER_4 = 11;
byte bytes[][6] = {
//blue //green //red
{B00000000, B00000000, B11000000, B00000000, B00000000, B00000000},
{B00000000, B00000000, B00110000, B00000000, B00000000, B00000000},
{B00000000, B00000000, B00001100, B00000000, B00000000, B00000000},
{B00000000, B00000000, B00000011, B00000000, B00000000, B00000000}
};
void setup() {
// put your setup code here, to run once:
pinMode(DATA_PIN, OUTPUT);
pinMode(CLOCK_PIN, OUTPUT);
pinMode(LATCH_PIN, OUTPUT);
pinMode(LAYER_1, OUTPUT);
pinMode(LAYER_2, OUTPUT);
pinMode(LAYER_3, OUTPUT);
pinMode(LAYER_4, OUTPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
// for(int i = 0; i<5;i++)
// {
digitalWrite(LAYER_1, HIGH);
for(int j = 0; j < 4;j++)
{
digitalWrite(LATCH_PIN, LOW);
for (int i = 0; i < 6; i++)
{
Serial.println(j);
digitalWrite(CLOCK_PIN, LOW);
shiftOut(DATA_PIN, CLOCK_PIN, MSBFIRST, bytes[j][i]);
}
digitalWrite(LATCH_PIN, HIGH);
delay(500);
digitalWrite(LAYER_1, LOW);
delay(500);
}
// }
}