Shop OBEX P1 Docs P2 Docs Learn Events
Triggering input pin with an output pin on the same BS2? — Parallax Forums

Triggering input pin with an output pin on the same BS2?

BlakeBlake Posts: 74
edited 2008-04-04 14:28 in BASIC Stamp
A simple technical question:

Can I use one pin (pin0) set to high output to trigger another pin (pin1) set to input on the same stamp? I would like to attach wires to the input and output pins spaced apart so that when they came into contact with a strip of metal they would act as a switch for the stamp. Would I need some resistors in this scenario?

Thanks,
Blake

Comments

  • ercoerco Posts: 20,260
    edited 2008-04-01 20:26
    Blake: Go easy on those pins, Cowboy! What you described is the long way around, and we Stamp lovers try not to waste pins. Any pin can be an input, 0-7 (BS1) or 0-15 (BS2 family). To be sensed properly, an input pin should be connected to either ground (0 volts or battery - terminal) or to Vcc (+5 volts). One way to achieve this is to install a high-value resistor like 10K (10,000) ohms from the input pin to ground. Then you add a simple on/off pushbutton switch (like a doorbell) to make and break contact from the same pin to +5 volts. Let's say the switch is normally open, and closes (makes contact) temporarily when you push it. When you don't push the switch, the resistor to ground is the only connection. That's a high resistance value, but no current flows and the pin will read low as far as the Stamp is concerned. When you press the button, the pin is connected directly to Vcc and the Stamp will read the pin high. The resistor is then also connected from Vcc to ground, and a very small current flows through it. Literally, half of a milliamp of current (5V/10,000 ohms). A lower value resistor would also work, but more current would flow and waste power. That's why we use high value resistors.

    Lots of educational info out there on ther Stamp. You should read the What's a Microcontroller book on basic switch inputs. Great place to start, and author Andy Lindsay explains it all very well. Good luck.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"If you build it, they will come."
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-04-01 20:29
    Blake -

    If you want a switch type of circuit, you must use a switch type device. The device can be an actual switch, or a relay, magnetic contacts, a micro-switch, or anything else that acts like a switch.

    The Stamp can only provide a + or - 5 VDC from its pin ports, period.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Involvement and committment can be best understood by looking at a plate of ham and eggs. The chicken was involved, but the pig was committed. ANON
  • BlakeBlake Posts: 74
    edited 2008-04-04 13:44
    Not to disregard what either of you are saying, but I don't think my question was really answered. I am pretty familiar with everything erco said (but thanks for the recap erco), but my simple question is really can one pin on a BS2 (supplying 5 volts, constantly, set to HIGH) act as the voltage supply for a switch connected to an input pin on the SAME BS2, so that when the normally off switch is thrown, the input receives the five volts from the first pin and is thrown high? I know it may seem silly to use two pins, but I've got a lot of extra pins, and it would suit my project.

    I hope I'm not reading your posts wrong guys,

    Thanks,
    Blake
  • allanlane5allanlane5 Posts: 3,815
    edited 2008-04-04 14:28
    First answer -- yes, you can do this.

    Second answer -- the problem is, when the input pin is "floating", in effect it has "no definite state". So you'll need a 10 Kohm 'pull-down' resistor on that pin (other side of resistor to Vss), to give that pin a default "low" state. Result -- when the switch is open, the input reads the 'low'. When the switch is closed, the state of the output pin is read.

    But it's easier to connect the 'far' end of the switch to +5, without using another I/O pin. Since you need the 10K pull-down in any case.

    Oh, another name for a "floating input" pin is "antenna". Without any termination, it usually picks up 60 Hz RF noise which LOOKS like a noisy signal.
Sign In or Register to comment.