Try this PaulJakob:
/* code for sending data to 4 shift register which are daisy chained together
MOSI goes to Serial In on chip 1 (pin 14), Q7/ (pin 9) goes to Serial In on chip 2, etc.
SCK goes to ShiftClock on all 4 devices (pin 11)
ss goes to RegisterClock on all 4 devices (pin 12)
SerialClear (pin 10) is pulled high on all 4 devices
Output Enable (pin 13) is pulled low on all 4 devices
0.1uF capacitor from each chip's Vcc to GND
*/
// used Sketch:Import Library:SPI to make this show up
#include <SPI.h>
int ss = 10;
int i = 0;
int shiftreg = 0;
byte byte1 = 1;
byte byte2 = 1;
byte byte3 = 1;
byte byte4 = 1;
void setup() {
pinMode (ss, OUTPUT);
SPI.begin(); // library takes care of D11 MOSI, D12 MISO, D13 SCK
}
void loop(){
// loop thru 8 times, walk a 1 across all 4 registers
for(i = 0; i < 8; i=i+1){
digitalWrite (ss, LOW);
SPI.transfer (byte1);
SPI.transfer (byte2);
SPI.transfer (byte3);
SPI.transfer (byte4);
digitalWrite (ss, HIGH); // all outputs change on ss going low to high
delay(1000);
byte1 = byte1 <<1; // update the data
byte2 = byte2 <<1;
byte3 = byte3 <<1;
byte4 = byte4 <<1;
}
// after all 8 outputs are high one time, reset for the next pass
byte1 = 1; // update the data
byte2 = 1;
byte3 = 1;
byte4 = 1;
}