Go Down

Topic: Buttons, I2C, interrupts and port-expanders (Read 2467 times) previous topic - next topic

Nick Gammon

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:

Please post technical questions on the forum, not by personal message. Thanks!

More info:


I can see a few people that would love to use this sort of stuff in their projects. Thankyou.
"Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent di

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131