Shop OBEX P1 Docs P2 Docs Learn Events
detect the out put of a limit switch — Parallax Forums

detect the out put of a limit switch

EvilMaroEvilMaro Posts: 27
edited 2007-05-25 07:22 in BASIC Stamp
I got my education board yesterday and i try to trouble shot to see what is the input to my pin1

below·is my program

Do

debug"Pin1 = ",dec1,in1

loop

i try to use these command to detect the out put of a limit switch but it is very unstable (sometime high and sometime low).

My switch is normal closed so by logic if there is no contact it should give a logic 1.

i connect my switch from a 5v source to a 10k resistor then to my pin.

pls advise

Thx

Post Edited By Moderator (Chris Savage (Parallax)) : 5/25/2007 2:17:20 PM GMT

Comments

  • skylightskylight Posts: 1,915
    edited 2007-05-25 07:17
    may be a debounce circuit is needed, read manual on BUTTON command
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2007-05-25 07:22
    EvilMaro -

    Depending on what kind of limit switch you are using, you may be seeing contact bounce. I beleive there is a section in the PBASIC Reference Manual which discusses contact bounce and how to supress it. As I remember, it's in the area of the BUTTON command.

    Additionally, since any pin port can only have one of two values (0 or 1) you may want to make the following change:

    FROM -

    debug"Pin1 = ",dec1,in1

    TO -

    debug"Pin1 = ",BIN1,in1

    or

    DEBUG ?, BIN1, IN1


    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sign In or Register to comment.