Hi, I would like to trigger an interrupt on the Arduino Mega 2560, but I would like to use a keypad button.
I think this would require 2 pins to be pulled low, so does the interrupt parameter allow for more than 1 pin to be inputted before the interrupt is performed?
I would like to use the hashtag on a keypad to trigger this interrupt.
If this is not possible then I will use a normal momentary switch instead.
You could set a pin change interrupt on the column pin for #, and the service routine could test the row pin for # to see if it is also held down. If it's not, you would just return from the ISR without doing anything.
The first thing to check is why you want to use an interrupt for reading a button.
Just write non-blocking code without delay() and do your button reading.
Typical methods for matrix keyboard scanning when idle are either...
a) Constantly cycle though the rows switching each to LOW output in turn, then check the column inputs for a low indicating if a key was pressed. Basically no different from what you’d be doing if there was an active key pressed.
b) Don’t bother with constant cycling when you detect no keys pressed (idle). Instead drive all of the rows low, and set an interrupt on the column pins. When you get an interrupt, switch to scanning mode to find out which row the key is in.
The second option is more complex. It does have the advantage that it requires no CPU cycles when the keyboard is idle. It’s also useful if you want the device to wake from sleep.