Pages: [1]   Go Down
Author Topic: Several switches connected to the same pin.  (Read 331 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 1
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

SW Scotland
Offline Offline
Edison Member
*
Karma: 13
Posts: 1313
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: January 10, 2013, 05:16:15 am by jackrae » Logged

UK
Offline Offline
Shannon Member
****
Karma: 183
Posts: 11114
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.)
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Johannesburg UTC+2
Offline Offline
Faraday Member
**
Karma: 60
Posts: 3242
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Have you looked for answers in the Learning, Reference, Products and Playground tabs on http://arduino.cc/en/ ?
Look here http://electronicsclub.info/ for basic electronics

Siena Italia
Offline Offline
Full Member
***
Karma: 2
Posts: 149
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Topsham, Vermont USA
Offline Offline
Edison Member
*
Karma: 23
Posts: 1752
... in The Woods In Vermont
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16459
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: January 10, 2013, 10:58:17 am by retrolefty » Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: