Shop OBEX P1 Docs P2 Docs Learn Events
How do you connect I/O pins like a switch — Parallax Forums

How do you connect I/O pins like a switch

Karl MatlackKarl Matlack Posts: 5
edited 2007-06-22 06:07 in BASIC Stamp
Is it possible to connect say P0 and P1 together as a normally open switch and then have code that connects them?

Comments

  • FranklinFranklin Posts: 4,747
    edited 2007-06-22 03:56
    What is it you are trying to do? Usually you tie the device between the pin and either 5v or ground (with a resistor in series for current protection). This assumes the device does not draw more current than the stamp pin can supply.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Mike GreenMike Green Posts: 23,101
    edited 2007-06-22 04:00
    No. All of the I/O pins consist of a circuit that either connects the pin to +5V or ground or connects the pin to some input circuitry that senses whether the input voltage is above or below approximately 0.8V.

    You can connect a relay to an I/O pin (like a reed relay designed for a 5V signal) that will act like a simple normally open switch. Some of them can be driven directly from the I/O pin (if they require maybe 15ma or less coil current). You do need a diode connected backwards (cathode to +5V) across the relay coil to protect the I/O pin. Look at the What's a Microcontroller tutorial for an example.

    There's also a device called an analog switch that can be driven from an I/O pin and provides a normally open connection between two pins. These have some resistance (maybe 100 ohms) in the closed connection and there are voltage limitations for any signal conducted (0-5V usually).
  • FranklinFranklin Posts: 4,747
    edited 2007-06-22 05:16
    Karl said...(in a pm)
    I have a wirless remote that functions a machine when you press a button on it. I and to have the code "PRESS THE BUTTON" for me. I have a wire soldered onto both pins of my actual button now I just need the code to connect them.
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-06-22 06:06
    Try shorting the switch pins with a 100-ohm resistor. If that activates the switch, and if the voltage across the open contacts is less than 30V, then an H11F1 PhotoFET will do the trick for you. Look it up on DigiKey's website. Drive the emitter from a Stamp pin through a 220-ohm resistor. Connect the detector pins to your switch contacts.

    Here's a link to the datasheet: www.fairchildsemi.com/ds/H1/H11F1.pdf

    -Phil

    Post Edited (Phil Pilgrim (PhiPi)) : 6/22/2007 6:11:49 AM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2007-06-22 06:07
    Karl,
    The easiest thing to use would be a reed relay like the 5V version here: www.jameco.com/Jameco/Products/ProdDS/138430.PDF. This one includes the protective diode. You simply connect the coil end with the anode of the diode to the I/O pin and the coil end with the cathode of the diode to +5V. A LOW statement closes the contact of the relay and an INPUT or HIGH statement lets the contact open. You connect the contacts across the button of the remote and it should work.
Sign In or Register to comment.