It works fine, but the sketch as it is can only handle 4 165's, I would like to add a couple more but I don't have the knowledge to modify the code for that.
Could somebody please give me some indications, or maybe point me another piece of code that can handle a bigger amount of chips?
#include<SPI.h>
byte latchPin = 10; // goes to data latch pin on shift register
byte dataArray[] = {8,}; // increase for as many shift registers are being used
// change counter in for loops to match
byte x; // for loop variable
void setup(){
pinMode (latchPin, OUTPUT);
SPI.begin(); // D13 goes to shift register clock, D12 goes to shift register dataout
SPI.begin(9600);
}
void loop(){
digitalWrite (latchPin, LOW);
digitalWrite (latchPin, HIGH); //capture the data on the input pins
for (x=0; x<8; x=x+1){
dataArray[x] = SPI.transfer(0); // send 0 out on MOSI while reading in on MISO
}
// send to serial monitor
for (x=0; x<8; x=x+1){
Serial.println(dataArray[x]);
}
delay(3000); // chance to look at data
} // end loop