Multiple switch detection

Hi forumites,

I am a veritable newbie in gadgeteer, but have been working in electronics for too many years.

I am looking to create a project with up to 8 buttons.

Ok, so what is the best way to detect any button press. As there is only the one interrupt on the Y socket, i was contemplating going out to an I2 GPIO variation and use that.

Anyone got any advice, ideas or inspiration on the most straightforward way of doing this?

Thanks.

Geoff.

Hi Geoff,

The Y socket definition only REQUIRES one interrupt capable pin, the other pins MAY be interrupt capable. To check this you would need to check the schematic of the mainboard you’re using to see if that is sufficient.

For alternatives, the DL40 is a good choice (using the DL40IO firmware) as you can use it’s interrupt capability fairly simply.

Check out the driver of the keypad

https://www.ghielectronics.com/docs/203/keypad-kp16

The source should be available on gadgeteer.codeplex.com

I can comment on the keypad - it uses an interrupt line for the enter key and you can poll the rest of the keys. If you want a more “eventing” approach you can always spool up a thread and poll the status and raise events based on state changes…

If you only have (or want to use) 1 Interrupt pin you could do as follows:
Use Buttons with two Independent contacts.
Connect contact 1 of all Switches to the Interrupt IO (all buttons in parallel)
Connect 2nd contact of button to an (non Interrupt) IO each.
Then listen to the Interrupt, and inside the event handler check the state of the other Inputs.
By this you would Need one more input, but only one Interrupt capable pin.