Shop OBEX P1 Docs P2 Docs Learn Events
Quick question about a simple switch — Parallax Forums

Quick question about a simple switch

NosePickerNosePicker Posts: 54
edited 2008-07-14 16:01 in BASIC Stamp
On the motherboard of most any computer there are two pins that usually are connected to two wires which runs to a spring switch on the case of the computer. I have measured the voltage of the motherboard I am testing with and it has 3v on one side of it. In testing I found if I simply connect the + side of the switch to any ground I get the desired response from the computer. So the next test I did was I wrote a program for my basic stamp which just had four lines of code:
output 7
output 8

OUT7 = 1
OUT8 = 0

then if I touched the + wire from the switch to pin 7 nothing seemed to happen which is what I would expect and when I touched the wire to pin 8 I got the desired response from the computer.

Is this safe? Is there any chance this will burn up my BS?·To connect a wire with 3v to an output pin and normally I would set the output pin to 1 then when I am ready to "switch it", I would set the output pin to 0, pause for about 250 ms then set it back to 1 again?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thanks

NosePicker

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-07-14 14:39
    This is more likely to damage your computer motherboard although by damaging your computer and possibly causing a short circuit, it could then damage your Stamp. Since you're measuring 3V, this is likely to be a pullup resistor to 3.3V and a logic input using 3.3V logic. This can be damaged by voltages above 3.3V. Your Stamp supplies 5V (when HIGH) although with limited current. The safest thing to do would be to use an NPN switching transistor (like a 2N3606). You connect the emitter to ground, the collector to the + side of the switch, then connect the base through a 1K resistor to a Stamp I/O pin. When the pin is HIGH, the transistor switches on. When the pin is LOW, the transistor is off.

    You could still use your setup by going between INPUT and LOW. That lets the + signal float or connects it to ground. The problem is that you don't know what's on the other side of the + wire. There might still be voltages or currents that could damage the Stamp. A transistor is cheap to replace and the transistor and resistor would partially isolate the Stamp from whatever is attached to the + line.

    Post Edited (Mike Green) : 7/14/2008 2:46:24 PM GMT
  • NosePickerNosePicker Posts: 54
    edited 2008-07-14 16:01
    Thanks I have done more reading about NPN transistors and this does seem to be exactly what I need. I would like to clarify one thing though. If making the base go high causes the collector to "connect or closes the circuit" with the emitter, then as you said the +3v from the motherboard switch should be connected to the collector, but shouldn't I just connect the emitter to the other wire from the motherboard?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thanks

    NosePicker
Sign In or Register to comment.