I've got a mass of I/O so I got a I2C I/O expander. (Sparkfun SX1509)
I had planned to address the I/O with arrays, so ...
for (int i=0; i<10; i++)
{
myData[i] = digitalRead(myButtons[i]);
}
But I've now found that to address the pins on the expander I need to use ...
for (int i=0; i<10; i++)
{
myData[i] = myObject.digitalRead(myButtons[i]);
}
Obviously the same applies to myObject.digitalWrite(myLeds*)*
Is there a simple way to code the read/write opperations so that myData is partly populated with myObject.digitalWrite() and partly with digitalWrite() ?
I've thought of a couple of solutions:
1) use two SX1509 expanders or
2) Or I think I could use something like the code below to write some sort of myReadFunction() and myWriteFunction(),
But I'm hoping there's a more elegant solution. Any clever ideas?
* *for (int i=0; i<5; i++) { myData[i] = myObject.digitalRead(myButtons[i]); } for (int i=5; i<10; i++) { myData[i] = digitalRead(myButtons[i]); }* *
Thanks.