Several switches connected to the same pin.

Hello, I want to connect several switches to the same pin interrupt.
Each switch has this schematic:
(upload://j5MzfXoPVvk5NrxSaaoLTCcNrh0.jpeg)]
But my switches are NC, normally closed, then, the arduino can not detect the interrupt of several switches. It can only detect if there is one switch connected.

Can anyone tell me how to solve this? How can i connected several switches NC to the same pin?

Thanks,
Regards.

One method would be to feed your input point as an analogue-in then each switch is across a different value of resistor in a divider chain. Since this will produce a differing input as the respective resistor is shortened, the A-In will read a differing voltage and be able to determine which switch is operated. Note that this system only caters for one switch being operated at any time. If you google R-2R you'll get info on how this is accomplished

jackrae:
Note that this system only caters for one switch being operated at any time. If you google R-2R you'll get info on how this is accomplished

Just to avoid any confusion, I'm sure that you intended to say that you can Google R-2R to get info on how to detect multiple simultaneous button presses. (Your original wording seems to imply that R-2R only caters for one switch being operated at a time.)

It was discussed on this very forum in this thread and Rob Tillaart gave this link which has a good diagram.

Let's see of I understand your question. You have several NC switches and you want to detect when any one of them has been pressed, but don't care to know which one has been pressed. Is that a correct understanding?

If so, the simplest solution is to merely wire the switches in series. If none are pressed, the arduino pin will be pulled down, if any switch is pressed, it doesn't matter which one, the pin will be high.

Ciao,
Lenny

Hi,
The OP said "Interrupt" pin.

I THINK that interrupts can be set for either + or - going.

But also if switches are in series, pulling down a pin, then pressing any pin or multiple pins will cause the pin to go high and interrupt.

tablet:
Hello, I want to connect several switches to the same pin interrupt.
Each switch has this schematic:
(upload://j5MzfXoPVvk5NrxSaaoLTCcNrh0.jpeg)]
But my switches are NC, normally closed, then, the arduino can not detect the interrupt of several switches. It can only detect if there is one switch connected.

Can anyone tell me how to solve this? How can i connected several switches NC to the same pin?

Thanks,
Regards.

Simple, you wire all your NC switches in series (and using no external resistors) and ground the far end of the switch array. Then you enable the user interrupt pin's (pins 2 or 3 on a Uno) internal pull-up resistor with a pinMode(pin#,INPUT_PULLUP); in your setup function. Then when you enable the interrupt with a
attachInterrupt(interruptNumber, functionName, RISING); command a interrupt will be generated when any switch is pushed.

Note that this is just the logic behind the method. In reality you need to deal with switch contact bounce which can be a bit tricky when dealing with switch generated interrupts, but that is another subject for another time.

Lefty

Hello, thanks for the help. I will wire the switches in series.
Thank you very much.