Go Down

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

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