Herodes:
Well, well ... IT WORKS !!!!
[...]
At least I know how it works !!!
Congratulations!
Herodes:
To finish, I had to take into account that the 74SN595 are numbered from 1, while the 74HC165 are numbered from 0. This has forced me to modify the line "registers [index] = value" to "registers [index + 1] = value; " and with this it has already worked as I wanted.
You should change your writeRegisters() function so that that 595 are also numbered from zero.
Your registers array is also numbered from zero. With 'index + 1', the last one will be outside the array. For now you won't run into this because you have declared 20 595s (160 registers: 0...159) but you use only 10 (80 registers, 0...79). But when you use all 20 of them, this will be an issue.
Some other advice:
You are now using 1 byte (8 bits) to store the value of each output. You could store 8 outputs in 1 byte: 1 per bit.
Herodes:
if (digitalRead(pin_Q7) == HIGH)
{
//Serial.print("1");
index = i;
value = HIGH;
setRegisterPin(index, value);
}
else
{
index = i;
value = LOW;
setRegisterPin(index, value);
}
This entire block can be simplified into one single line. Basically: you set each register pin to the value you read from the input pin ... but it's not important as this is just a test.