Dear community,
I am new to the world of programing Arduino and connected two MCP23017 to my microcontroller using the slightly ameded interupt example code from the Adafruit MCP23xxx library which works perfectly fine. But I want to use 8 MCP23017 in the final project and am wondering if there is a way to put the following part into an array to use a loop for seting up each chip:
Adafruit_MCP23X17 mcp1;
Adafruit_MCP23X17 mcp2;
Using the wire.h library I used a for loop like this:
const uint8_t MCP_ADDRESSES[]={0x20, 0x21};
// set I/O pins to outputs
for (int i=0; i<=sizeof MCP_ADDRESSES; i++) {
MCP_CHIP = MCP_ADDRESSES[i];
writeRegister(MCP_CHIP, MCP_IODIRA, 0b00000000);
writeRegister(MCP_CHIP, MCP_IODIRB, 0b11111111);
writeRegister(MCP_CHIP, MCP_GPPUB, 0b11111111);
}
I would like to do the same with the Adafruit_MCP23017 library. Do you have a idea how to do it?
Thanks a lot in advance!
Best regards
BrainPaiN