help me improve my code for controlling 64 leds with 2 74HC595N ic's

frankvnz:
Just a general comment on coding style: If you're representing bit patterns, do NOT write the equivalent number in decimal. Write in hex or binary (or octal, if you must). The issues with 132, 253, 147 etc that were mentioned earlier would have been more immediately apparent.

Looking at your circuit, I guess the idea is to output 0V to the negative side of an LED and 5V to the positive side; the LED will illuminate. An RGBW LED is actually 4 LEDs in one package, so you actually have 256 LEDs to control, hence you need to use all 8 bits of both shift registers. It would be helpful to know exactly what the logical arrangement of the LEDs vs shift registers is. Do you see it as 4 rows of 16 LEDs, with 4 outputs to select the colour? Or an 8x8 grid of LEDs, with a 2x2 combination to select the colour?

But, generally speaking, if you output 0x01 to the positive side of the LED matrix and 0xFE to the negative side, you should illuminate one colour of the LED at the bottom left corner of your matrix.

Beware that turning on more than one LED in a row or column may exceed the current capabilities of a shift register (35mA) and possibly destroy it. Probably you should have 8 transistors controlled by each shift register to deliver the current to the LEDs. But then you somehow need to limit the current flowing through each LED.

So, for the positive side, values you should use are one of: 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80.
For the negative side, you want one of the inverses of those: 0xFE, 0xFD, 0xFB, 0xF7, 0xEF, 0xDF, 0xBF, 0x7F.

To cycle through bits, the << operator is useful. e.g. the following (untested code!) will cycle through all your LEDs.

Well actually its not all in one LED, Rather the pattern is R = red, G = green, W = White and B = Blue
so theres one color LEDs just assorted in the 64 array.
R G B W R G B W
G B W R G B W R
B W R G B W R G
W R G B W R G B
R G B W R G B W
G B W R G B W R
B W R G B W R G
W R G B W R G B
My main issue is im having trouble controlling the ground and and anodes of the LEDs with the 2 74HC595s. I was going to follow what Paul_B said and use 1k ohm resistor to see if it would fix the issue, I can get a row of LEDs to light up but I cant choose which one specifically to light up and only the Red and Green light up, not blue or white, so theres that issue too.

So i used your code, and i even sent the grounded 595 bits to 0 and it didn't affect it at all. Heres the code for

int latchPin = 6;  //Pin connected to groundd
int clockPin = 5;  //Pin connected to  ground
int dataPin = 7;   //Pin connected to ground

int latchPin2 = 3;  //Pin connected to vcc
int clockPin2 = 2;  //Pin connected to vcc
int dataPin2 = 4;   //Pin connected to vcc

void setup() {
  //output to control shift register
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);

  pinMode(latchPin2, OUTPUT);
  pinMode(clockPin2, OUTPUT);
  pinMode(dataPin2, OUTPUT);
  int i = 0;
}

void loop() {




/*  digitalWrite(latchPin, LOW);
  //Send 1 1 1 1 1 1 1 1 (255) to Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0 of 1st 74595
  shiftOut(dataPin, clockPin, MSBFIRST, 5);
  // shifting out the bits:
  digitalWrite(latchPin, HIGH);



  digitalWrite(latchPin2, LOW);
  //Send 0 0 0 0 0 0 0 0 (0) to Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0 of 2nd 74595
  shiftOut(dataPin2, clockPin2, MSBFIRST, 10);
      delay(250);
  // shifting out the bits
  digitalWrite(latchPin2, HIGH);

  digitalWrite(latchPin, LOW);
  //Send 1 1 1 1 1 1 1 1 (255) to Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0 of 1st 74595
  shiftOut(dataPin, clockPin, MSBFIRST, 0);
  // shifting out the bits:
  digitalWrite(latchPin, HIGH);

  digitalWrite(latchPin2, LOW);
  //Send 0 0 0 0 0 0 0 0 (0) to Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0 of 2nd 74595
  shiftOut(dataPin2, clockPin2, MSBFIRST, 4);
        delay(500);
  // shifting out the bits
  digitalWrite(latchPin2, HIGH);
}
*/

for (int x = 1; x < 0x100; x <<= 1) {
  digitalWrite(latchPin, LOW);
  //Send x to Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0 of 1st 74595
  shiftOut(dataPin, clockPin, MSBFIRST, 0);  // shifting out the bits:
  digitalWrite(latchPin, HIGH);

  for (int y = 1; y < 0x100; y <<= 1) {
    digitalWrite(latchPin2, LOW);
    //Send inverse of y to Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0 of 2nd 74595
    shiftOut(dataPin2, clockPin2, MSBFIRST, ~y);  // shifting out the bits NB: inverse Y
    digitalWrite(latchPin2, HIGH);
    delay(1000);
  }
}
}

I feel like the the anode portion of the 74HC595 is working but for some reason I cant control the grounded 595, it seems to always have grounded on for all the LEDs no matter what bits i send. Im not extremely knowledged in multiplexing so i think it may be a software issue im doing wrong

This was the results