Buttons, I2C, interrupts and port-expanders

As part of my ongoing attempt to make a nice standalone adventure game, I have been experimenting with using interrupts to detect button presses, via the MCP23017 16-bit I/O port expander.

It's all working quite well, the code detects and reacts to a button click, even if it is busy in a loop of thousands of iterations.

The MCP23017 can be configured to generate an interrupt signal if any of the 16 ports connected to it change value, so that can be used to notify the Arduino code. It also remembers the values on the ports at the time of the interrupt (rather than at the time you actually get around to testing it) which is helpful for knowing exactly what keys were pressed, even a second later.

More details here:


I can see a few people that would love to use this sort of stuff in their projects. Thankyou.