Controlling 8x8 LED Matrix using 2x 74595

One 74595 is directly connected to the anodes.
The second one is connected to the base of 8 2N3904 NPN transistors that are connected to the ground through a 150 Ohm resistor on the emitter and the collector is connected to the 8x8 matrix cathodes.

int latchPin2 = 5; //74595 connected to ANODES
int latchPin = 4; //74595 connected to CATHODES
int clockPin = 2; //Shared clockPin, but under this troubleshooting the clockpin is only connected to the anode controlling 74595
int dataPin = 3; //Shared dataPin, but under this troubleshooting the datapin is only connected to the anode controlling 74595

byte data;
byte dataArray[8]; //Array to set the leds

void setup() {
  Serial.begin(9600);
  pinMode(latchPin2, OUTPUT);
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  Serial.println("Ready");
  
  dataArray[0] = 1; //Tried hexadecimal so I've now tried just normal decimals.
  dataArray[1] = 2;
  dataArray[2] = 4;
  dataArray[3] = 8;
  dataArray[4] = 16;
  dataArray[5] = 32;
  dataArray[6] = 64;
  dataArray[7] = 128;
}


void loop() {
  for(int i = 0; i < 8; i++)  {
    data = dataArray[i];
    digitalWrite(latchPin2, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, data);
    digitalWrite(latchPin2, HIGH);
    Serial.println(i, DEC);
    delay(2500);
  }
}

It works just fine when running the 0x0F / 0xF0 hex array, but with every other combo every second array doesn't light up. It only shows 0, 2, 4, 6 or 1, 3, 5, 7. And it seems totally random which it will show, I'm a bit confused about this.

Changed the other 74595 to a 4022, works a bit better now.

I'm not sure how well it'll work for an LED matrix, but when I use shiftOut, I like using Binary, just for the visual effect. Each 1 will be a pin HIGH, and a 0, will be a LOW. For example:

B10000000 will light up the first output on the 595.
B01000000 will light up the second output, etc.

Just easier to visualize for me, rather than hex numbers, or even regular decimal :smiley:

You can also use bit math to shift binary 1's over.
B10000000 >> 1 // == B01000000

http://www.arduino.cc/playground/Code/BitMath
Also, here's an uber Arduino manual with great examples for 595's. (Hardware setup and code)
http://earthshinedesign.co.uk/ASKManual/ASKManual.pdf
It's down a bit, just check the index. It's hard to resist reading it though, all the information is crazy useful.. explains the code in depth for every example, and he's updating it as he does more examples!
But anyways.. :X hope this helps!:smiley: