Shop OBEX P1 Docs P2 Docs Learn Events
Can somebody help an idiot? — Parallax Forums

Can somebody help an idiot?

ArchiverArchiver Posts: 46,084
edited 2001-01-21 20:27 in General Discussion
Hello,

Can somebody help me with a problem I'm sure has a super simple solution that this idiot is overlooking...

I'm making a simple security alarm·for my garage, my problem is with switching:

I'm running a wire from the +5 pin on my Stamp D to pin 0, I set pin 0 as input, but whenever I debug it, it works fine as long as the switch is closed... however, the minute the switch opens, debugging it returns 0 or 1 intermittently... Is there something that needs to be installed inline to keep it from wigging out?

Thanks a bunch in advance, your help is greatly appreciated!

-Ben Wampler

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2001-01-21 20:27
    At 2:55 PM -0500 1/21/01, Ben Wampler, you wrote about [noparse][[/noparse]basicstamps]
    Can somebody help an idiot?:
    >
    >I'm running a wire from the +5 pin on my Stamp D to pin 0, I set pin
    >0 as input, but whenever I debug it, it works fine as long as the
    >switch is closed... however, the minute the switch opens, debugging
    >it returns 0 or 1 intermittently... Is there something that needs to
    >be installed inline to keep it from wigging out?
    >

    It's called a pull-down resistor (in this case).

    Input pins on many (most?) devices will 'float high' when not
    connected to anything. This is what is happening (I think) when your
    security switch opens. Put a 10k resistor from pin 0 to ground. While
    the switch is closed the R will draw negligible current and will
    ensure that pin 0 'goes low' when the switch is opened.

    (others are welcome to chime in with other suggestions)

    It's no accident that stressed Chuck Britton
    spelled backwards is desserts. britton@n...
Sign In or Register to comment.