Problem making a 5x5x5 led cube work with 74hc595n

Hello everyone, for the past few days I have been trying to program my 53 led cube with little to no succes. After soldering the cube I have tested everything to see if there is no shorting in the circuit everything was good. I then attached cables to the layers and the columns of the cube and i prototyped the control circuit on a bread board. I am using 6 74hc595n shift registers with 10nf capacitors across their vcc and ground, 5 registers for each row and 1 for the layers. The layers sink to ground through 5 2n3906 transistors. For the 595's, master reset is pulled high while the output enable is pulled low, the register and latch clocks are the same for each one and i have daisy chained each one, pin 9 from the first one goes into pin 14 of the second and so on. I am powering everything from a 5V 500 mA supply (which is an old phone charger, I think it may be relevant).

For the code part of things, i have tried to make them work using the SPI library, but everything i tried failed. There is one piece of code that has worked for me, demonstarting that multiplexing works, but if i try to modify anything starting from that piece of code I get random leds turning on or no leds at all.

#define latch 8 //red

#include <SPI.h>
uint8_t cube[5][5];
int grow=0;
int looplimit=600;
int deltime=2;

void setup() {
  // put your setup code here, to run once:
  loading = true;
 
  SPI.begin();
  SPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0));

}

int i;
void loop() {
  // put your main code here, to run repeatedly:
lightCube();
renderCube();

}

void lightCube() {
  for (uint8_t i = 0; i < 5; i++) {
    for (uint8_t j = 0; j < 5; j++) {
      cube[i][j] = 0B11111;
    }
  }
}

void clearCube() {
  for (uint8_t i = 0; i < 5; i++) {
    for (uint8_t j = 0; j < 5; j++) {
      cube[i][j] = 0;
    }
  }
}

void renderCube() {
  for (uint8_t i = 0; i < 5; i++) {
    digitalWrite(latch, LOW);
    SPI.transfer(0x01 << i);
        //digitalWrite(latch, HIGH);

    for (uint8_t j = 0; j < 5; j++) {
          //digitalWrite(latch, LOW);

      SPI.transfer(cube[i][j]);
          //digitalWrite(latch, HIGH);

    }
              digitalWrite(latch, HIGH);

    delay(deltime);
    grow++;
    if(grow==looplimit){
    deltime+=10;
    grow=0;
    if(looplimit>1)
    looplimit=looplimit/2;
    }
  }
}

One thing i noticed with the code is that only the first row of the matrix cube[][] is taken into consideration, me giving values to cube[1][3] or cube[4][0] will not turn on any led.

I also tried to swap out the 3906 for a 3904 which would heat up the last shift register, and an IRF3025 MOSFET to no succes, same result.

In conclusion my questions are:

  • Is my code incorrect or is it a hardware issue?(not using correct parts, something is not tied well, etc)
  • What is the difference between 74hc595 and 74hc595n as I didn't find an answer online.

Please post a real schematic. Nobody can make any sense of this:

I am sorry for not posting a schematic. The problem is, I don't exactly have a schematic of my own, I have followed this diagram for an 8x8x8 led cube. I have basically wired them the same, but there are 6 shift registers instead of 9. And also one transistor instead of a pair of transistors, because by my calculations one should handle the collector current.

Hope this helps.

CUBE-SCHEMATIC.pdf (58 KB)