I have an arduino Leonardo project with multiple buttons going through a 4051 mux/demux and rather than continuously polling them, I would like to send an interrupt whenever a button has been pressed or released, telling the sketch to check the buttons and find which one changed. I have seen some examples of how to use diodes to signal the pin if a button has been pressed, but not with a multiplexer and not if pressed OR released. I imagine that being able to detect both conditions with multiple buttons may be a problem.
It is possible as long as only one button at a time is pressed ALL THE TIME. Then you can indeed OR all button signals and check that changing state. But that's not a condition I would like in a control panel...
Other option would be to use a port expander like the PCF8574 which has a interrupt line.
Yeah, the only one button at a time, limit is exactly the problem that I am running into. The port expander sounds like something to look into though. I'll go dig up some datasheets and see if it could solve the issue.
Meanwhile, if anyone else has any suggestions I'm all ears. This just seems like a common issue where multiple buttons are concerned, you would think there would be a more standard answer.
I think IO expander is "more standard answer" for multiple buttons than (de)mux. Mostly because you can read all buttons at once, use it also as an output etc.