Shop OBEX P1 Docs P2 Docs Learn Events
Newb with simple question: Limit Switch and BS2 — Parallax Forums

Newb with simple question: Limit Switch and BS2

hammatronhammatron Posts: 1
edited 2011-10-25 14:37 in BASIC Stamp
I basically want to have the leads from a limit switch (closed when switch is not depressed) on the breadboard, and have the programming only GOTO if the limit switch is pressed (circuit is open).

I currently have one lead routed to the breadboard and to P15, and the other lead to the breadboard and to an open position in Vdd.
The code is written as

Check:

IF LS = 1 THEN Check
IF LS = 0 THEN Next

Next:
.
.
.


Any help is very much appreciated

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-10-25 14:37
    Look in the "What's a Microcontroller?" tutorial or in the section of the Basic Stamp Syntax and Reference Manual on the BUTTON statement for diagrams for hooking up a button or switch to a Stamp pin. What's missing from your description is a pullup or pulldown resistor. In your case, you need a resistor of about 10K from the I/O pin to Vss to provide a voltage for the Stamp pin when the switch is open. When the switch is open, the value of the I/O pin will be 0. When it's closed, the value will be 1.
Sign In or Register to comment.