IO Abstraction library fully supports the MCP23017 16-bit IO expander chips on Arduino and mbed. It requires only two pins (three for interrupt mode) SDA, SCL, and optionally INT. Our driver provides nearly all functionality using similar terminology to Arduino itself.
The MCP23017 provides 16 additional input or output ports, they have very similar capabilities to device pins and interrupt support is managed per pin. This device can be used for switches, rotary encoders, and with LiquidCrystalIO.
As above, the i2c communication bus is used to read and write values. You will need to know the address of the device, use this i2c address scanner if unsure. IO capabilities are almost identical to that of the Arduino, there are few limitations. However, I recommend if you are doing heavy writing and heavy interrupt based reading, then try to keep each on separate ports if possible.
// create an IO device that has no interrupts
MCP23017IoAbstraction io23017(address, optionalWirePtr);
// create an IO device that has an interrupt per 8-bit port
MCP23017IoAbstraction io23017(address, interruptMode, interruptPinA, interruptPinB, optionalWireImpl);
// create an IO device that has a single interrupt for both ports
MCP23017IoAbstraction io23017(address, interruptMode, interruptPin, optionalWirePtr);
See the reference docs for parameter details
Once you have created an instance, simply use it like any other IoAbstraction they all work the same way.
There are packaged samples for both LiquidCrystalIO and IoAbstraction that show how to use this device.