Go Down

Topic: Buttons connected to Interrupt and digital Pin (Read 491 times) previous topic - next topic


Hi, I like to use 24 Buttons (using Arduino Mega). So I dont like to check them all each time on the loop function, I like to "bundle" them into 4 groups with each 6 Buttons. Each group should have theire own Interrupt.
So a Button should be connected to a Interrupt and a digital pin. Is this possible? How would the circuit diagram look like?
Any Help or Idea would be greate.


Mar 03, 2018, 02:42 pm Last Edit: Mar 03, 2018, 02:45 pm by knut_ny
If you need 4  interrupts?.. use the reserved external interrupt pins.
page 101 in this datasheet

see pins 18..21


The Mega doesn't expose many of its pins as pin change interrupt pins (pin change libraries exist), but has more
direct interrupt pins as used with attachInterrupt().

[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]


So I dont like to check them all each time on the loop function,
But you will have to check the flags that tell you a button has been pressed so you are not winning much.

Beginners often use interrupts when their is no need.


Thank you for all your feedback.
I think about to use 4 interrupt pins and attachInterrupt. On each interrupt I will check the status of 6 buttons. What do you think about this wiring diagram:


I've used a similar approach, with hardware switch debouncing

"Who is like unto the beast? who is able to make war with him?"
When all else fails, check your wiring!

Go Up