Author Options:

How to interface a microcontroller with a switch? Answered

I have a device with a lever-style switch, like the bottom switch in the picture of this article. http://en.wikipedia.org/wiki/Miniature_snap-action_switch

With some multimeter probing, i found that of the three pins, the middle is unconnected. The left pin is always connected to ground. The right pin is connected to ground when the switch is unpressed. When the switch is pressed, the right pin is unconnected. How can I use a microcontroller to stand in for this switch? I'd like to have it activate the switch every 2 seconds. I have the software done, and just need to get the hardware set up. Help is apreciated.


Use a relay. Trigger the relay with the microcontroller, via a transistor. Connect its common pin to the "left pin", connect the Normally Closed pin to the "right pin"


Yes, but then when the rlay actuates, the original switch is still closed. I forgot to mention: I want the device to retain its original fuction. Is it impossible?

But even when the relay breaks the connection, there will still be conductivity through the original switch. Thereby having the device beleive nothing has happened.

Genius. One problem. The existing switch is mounted to a PCB in the device. How do I connect the relay to the switch's circuit?

When you say cut a track, do you mean to break the pcb trace connecting the switch to ground?

Wonderful. I think I can do that. Thank you for all your help. I'll be sure to credit you when I finish my project.