I would like to use 7 MCP23S17 as output expanders on one SPI bus. Every IC has its own address from 0 to 6. The first MCP23S17 can be written with no problem. The second chip did not work properly. The CS pin of the MCP23S17 is set like at the all other 4 ICs.
Does anybody have experience with more then 4 MCP23S17 on SPI? Could anyone help?
#include <SPI.h>
#include <MCP23S17.h>
MCP A(0, 10);
MCP B(1, 8);
int d = 250;
void setup() {
A.begin();
B.begin();
for (int k = 1; k <= 16; k++) {
A.pinMode(k, OUTPUT);
B.pinMode(k, OUTPUT);
}
}
void loop() {
//////////// ON THE LIGHT ONE BY ONE FROM BEGGING
for (int f = 1; f <= 16; f++) {
A.digitalWrite(f, HIGH);
delay(d );
}
for (int f = 1; f <= 16; f++) {
B.digitalWrite(f, HIGH);
delay(d );
}
//////////// OFF THE LIGHT ONE BY ONE FROM BEGINNIG
for (int f = 1; f <= 16; f++) {
A.digitalWrite(f, LOW);
delay(d);
}
for (int f = 1; f <= 16; f++) {
B.digitalWrite(f, LOW);
delay(d);
}
}