Go Down

Topic: Several switches connected to the same pin. (Read 445 times) previous topic - next topic

tablet

Hello, I want to connect several switches to the same pin interrupt.
Each switch has this schematic:
http://www.arcan.es/wp-content/uploads/2009/03/reset.jpg[/img]]
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.

jackrae

#1
Jan 10, 2013, 11:12 am Last Edit: Jan 10, 2013, 11:16 am by jackrae Reason: 1
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

PeterH


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.)
I only provide help via the forum - please do not contact me for private consultancy.

JimboZA

It was discussed on this very forum in this thread and Rob Tillaart gave this link which has a good diagram.
Roy from ITCrowd: Have you tried turning it off an on again?
I'm on LinkedIn: http://www.linkedin.com/in/jimbrownza

LROBBINS

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

terryking228

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.
Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

retrolefty

#6
Jan 10, 2013, 04:56 pm Last Edit: Jan 10, 2013, 04:58 pm by retrolefty Reason: 1

Hello, I want to connect several switches to the same pin interrupt.
Each switch has this schematic:
http://www.arcan.es/wp-content/uploads/2009/03/reset.jpg[/img]]
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

tablet

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

Go Up