Go Down

Topic: Buttons, I2C, interrupts and port-expanders (Read 1 time) 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:

http://www.gammon.com.au/forum/?id=10945
http://www.gammon.com.au/electronics

fliggygeek

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