Pages: [1]   Go Down
Author Topic: Buttons, I2C, interrupts and port-expanders  (Read 1808 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
Offline Offline
Brattain Member
*****
Karma: 495
Posts: 19031
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged


Australia
Offline Offline
Full Member
***
Karma: 8
Posts: 161
You dont have to touch powerlines for them to kill you, even looking at them for too long will make them angry.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

"Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent di

Pages: [1]   Go Up
Jump to: