Maximum Shift Register for a set of Arduino pins used

Hello,
First things first, if this is in the wrong section, feel free to move it.

I am trying to control as many as 160 transistor switches with Arduino and I am using IC 74HC595 to expand my outputs. I know that the 74HC595 needs at least 3 active signal pins (DS/Data, SHCP/Clock, and STCP/Latch). I am actually putting the ICs in row series of ICs, connecting their Serial Out to the next exact same IC.

The thing that I would like to confirm here, is it possible for only 3 active signal pins to control 20-in-series IC 74HC595? or there are any limits to those 3 pins can control?

Help me. Thanks. :smiley:

That's not a problem, but keep in mind that the more you ICs you chain the slower will they get.

Yes, you can chain that many. You may want to buffer clock and latch lines, drive 10 chips each or similar.
Using SPI.transfer to send the 20 bytes out, you can do an update in about 25uS at 8 MHz SPI clock:

digitalWrite (ssPin, LOW);
SPI.transfer(dataArray[0]);
SPI.transfer(dataArray[1]);
SPI.transfer(dataArray[2]);

:
:
SPI.transfer(dataArray[17]);

SPI.transfer(dataArray[18]);

SPI.transfer(dataArray[19]);

digitalWrite (ssPin, HIGH); // outputs update on this rising edge

Don't use a for loop, that will add a lot of time.

Hoo, Thanks for the fast replies, Shpaget & CrossRoads. I think I am confident now.

CrossRoads, as you show on your codes. So, SPI.transfer works like shiftout function, isn’t it? and is that digitalWrite somewhat like latching procedure?

SPI transfer is faster than shiftout. Make sure you wait for sufficient time before latching. Each shift register adds propagation delay so 20 of them will be significant so you can't just latch after you shift out everything.

And SPI absolutely requires certain pins, 11 for data out and 13 for the clock signal where shiftout lets you use any pins you want.