Go Down

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

digitalWanderer

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.

knut_ny

#1
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
Ny

MarkT

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 ]

Grumpy_Mike

Quote
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.

digitalWanderer

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:
http://forum.arduino.cc/index.php?action=dlattach;topic=220899.0;attach=70633


runaway_pancake

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