Can I make an interrupt using 2 pins? Keypad interrupt.

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.

Thanks in advance for any help. :)

Nize.

Why would a keypad work that way? You normally have to scan keypads explicitly.

Oh, I was forgetting that you would scan for the row - Sorry about that, I'm a beginner, so even this is a little confusing.

So would I be best to just create a normal attach interrupt command, triggered by any key on the keypad?

I was hoping to create 2 different interrupts using 2 different inputs from the keypad (# and *).

Could you suggest what commands I should be learning to be able to program this type of interrupt?

Thanks for your reply.

Nize.

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.