More than one 74HC595

hi all,

cant figure it out how to write code for more than one 74HC595.
I want connect 16 leds and make fade effect using 74HC595.

my code for one 74HC595:

int latchPin = 8; // 74HC595 leg 12
int clockPin = 12; // 74HC595 leg 11
int dataPin = 11; // 74HC595 leg 14
int outputEnablePin = 3; // 74HC595 leg 13

byte leds = B10010001;
byte b = 0;

void setup()
{
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(outputEnablePin, OUTPUT);
}

void loop() {
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, leds);   
    digitalWrite(latchPin, HIGH);
    //delay(1000);

    for (b = 0; b < 256; b++)
  {
    setBrightness(b);
    delay(10);

    if(b == 255) {
      delay(2000);
      }
  }
} 

void setBrightness(byte brightness) // 0 to 255
{
  analogWrite(outputEnablePin, 255 - brightness);
}

If I wire another 74HC595 and run code the other 8 leds do the same fade but with random leds. If I upload same code again firs 8 leds work fine but other 8 random again and do the same fade.

How can I define each 74HC595 x 2 output from 0 to 15 in code?

You're only shifting data to one chip here

void loop() {
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, leds);   
    digitalWrite(latchPin, HIGH);

Add a 2nd shiftout()

void loop() {
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, leds);   
     shiftOut(dataPin, clockPin, MSBFIRST, more_leds);
    digitalWrite(latchPin, HIGH);

and come up with data for more_leds.

oh man you are amazing! Thank you!

You're welcome. Pretty simple so far tho ...