Multiple buttons with one interrupt

Hi there. Here is the project description: You have 6 buttons and 6 LEDs. When one is pressed, the corresponding LED turns on for a few seconds. No other button presses will be registered during those few seconds. After those few seconds, repeat.

Basically I want to have 6 separate interrupts. Currently I have the interrupt setup, but whenever I do a digitalRead, all 6 buttons show up as pressed. Here is my layout:

I have pullup resistors enabled on all button pins. I can also see why all the buttons show up as pressed when I press just one. However, I have not been able to come up with a solution. I'd prefer not to use any solution that involves analogRead() because it doesn't handle multiple buttons at a time very well.

Can anyone help me come up with a solution?

One solution would be to make all the blue wires a "wired OR gate" connection to the interrupt pin. You can do this by adding a simple diode to each switch where you show the blue connection going to the common connection point and then on to the interrupt pin. The cathode end of each diode should wire to it's switche and the anode to the common connection.

That make sense?


Basically I want to have 6 separate interrupts

Why? What does an interrupt give you that isn't available through other means?

Thanks for the quick reply. I can't believe that the solution I was asking for fit "NOR gate" perfectly and I couldn't see it.

Even if I had seen that though, I would have immediately looked at logic ICs. I wouldn't even have considered the ultra simple solution of using diodes. I'm surprised the solution was that simple. BTW I just tested it and it works. Thanks!

Now I just have to find room on this crazy breadboard for 6 diodes. (when I am done I want to have all the LEDs and diodes + an ATMega328 all on a half-size breadboard)

Now I just have to find room on this crazy breadboard for 6 diodes.

There appears to be enough free holes for 6 diodes to the right of all the blue wires using both top and bottom holes.


If you had the Arduino off doing something else that takes a lot of resources, THEN maybe you would need an interrupt to alert it to come back and look at the buttons. But your code is doing nothing but looking at the buttons and timing and controlling the LEDs. At least we presume that is what your code is doing absent the ability to see it.

I know it's doing nothing but looking at the LEDs, but that using interrupts is still "best practice", right? It probably doesn't save battery power, but I think it makes it a lot more intuitive because that's what interrupts were made for.

Not clear why you have THREE connections to each button. Those buttons are typically 2-terminal devices, single-pole, single-throw, normally-open. switches. Looks like all the blue wires are superfluous (or else the black ones or the white ones, depending on what buttons you are using.)

The blue connections are necessary to connect all the buttons to the interrupt pin. If each pin had its own interrupt, I would only need two connections to each pin.

I see what you are saying though. I could have saved all the blue wires by changing from an interrupt-based program to update-based. For this project, the update-based was probably a better option. It just seemed more intuitive coming from a Java environment to use interrupts without considering the added complexity.

Now I just have to find room on this crazy breadboard for 6 diodes.

You might not need all 4 of the bus connections on the breadboard for power. If not, you could steal one for the interrupt line. Then you can use the diodes as jumpers between the switches and the bus line.