Hello.
I built a 4x4x4 LED Cube using an arduino nano. It does have enough pins for the way I wired up my LEDs. I have 4 common negative(CN) pins, pins A2-A5, one pin per layer and 16 common positive(CP) pins, pins D0-D13 and A0-A1, one pin per collomb.
I have trouble using the arrays to specify what pin I am working with. For instance, if I want to turn on all the LEDs and light them up 1 layer at a time, my code would look like follow in theory:
int i, j, k;
int arrCP[4][4] = {{0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}, {12, 13, A0, A1}};
// 0-13 represents pins D0-D13 on the board.
Int arrCN[4] = {A2, A3, A4, A5};
void setup(){
// Set CP pins as OUTPUT.
for(i=0; i<=3; i++){
for(j=0; j<=3; j++){
pinMode(arrCP[i][j], OUTPUT);
}
}
// Set CN pins as OUTPUT.
for(j=0; j<=3; j++){
pinMode(arrCN[i], OUTPUT);
}
}
void loop(){
// Turn all Layers off: Layer CN must be HIGH
// to turn the Layer off and LOW to turn the
// Layer on
for(i=0; i<=3; i++){
digitalWrite(arrCN[i], HIGH);
}
// Turn every collomb on.
for(i=0; i<=3; i++){
for(j=0; j<=3; j++){
digitalWrite(arrCP[i][j], HIGH);
}
}
// Turn Layer by Layer on then off 3 times up
// and down.
for(k=1; i<=3; i++){
for(i=0; i<=3; i++){
digitalWrite(arrCN[i], LOW);
delay(200);
digitalWrite(arrCN[i], HIGH);
}
}
}
The problem I'm haveing is that the LED Cube does not light up at all and the RX, TX, POW and L LEDs on the nano all light up after I upload the code. No errors in the code are displayed.
If I code the peogram without arrays and for loops, the LED Cube lights up as it should.
Can someone please help me?
ToxicTeddyBear