994Views11Replies

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.

11 Replies

user
steveastroukBest Answer (author)2012-06-02

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"

Steve

Select as Best AnswerUndo Best Answer

user

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?

Select as Best AnswerUndo Best Answer

user

Yes. Put it in parallel with the existing switch.

Select as Best AnswerUndo Best Answer

user

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.

Select as Best AnswerUndo Best Answer

user

Put the Relay in series with the switch. Sorry.

Select as Best AnswerUndo Best Answer

user

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?

Select as Best AnswerUndo Best Answer

user

Cut a track, insert the relay connections across the break.

Select as Best AnswerUndo Best Answer

user

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

Select as Best AnswerUndo Best Answer

user

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.

Select as Best AnswerUndo Best Answer

user

Don't forget to tick the Best answer box !

Steve

Select as Best AnswerUndo Best Answer