Shop OBEX P1 Docs P2 Docs Learn Events
Detect ground closure — Parallax Forums

Detect ground closure

docwisdomdocwisdom Posts: 28
edited 2009-10-08 16:47 in BASIC Stamp
I have a button that I want to detect a press between a pin and ground. I dont have the luxury of pushing 5v to the pin to detect high.
I figure using a resistor to supply 5v constant to the pin and then detect low when the pin is grounded.

Any recommendations on proper circuitry and code?
This will be a reset button that will get someone out of an error subroutine

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-10-08 16:24
    There are examples in the "What's a Microcontroller?" tutorial and in the Basic Stamp Syntax and Reference Manual. As you said, all you need is a pullup resistor (to +5V) and the switch closure between the pullup and ground. The pullup resistor could be any value from around 220 Ohms to over 10K Ohms. You'd want a lower resistance in electrically noisy conditions or a higher resistance to reduce the power used when the switch is closed.
  • docwisdomdocwisdom Posts: 28
    edited 2009-10-08 16:47
    Thanks! Ill check out that reference.
Sign In or Register to comment.