Shop OBEX P1 Docs P2 Docs Learn Events
Writting code for multiple microswitches connected to basic stamp II — Parallax Forums

Writting code for multiple microswitches connected to basic stamp II

ltmhallltmhall Posts: 102
edited 2007-01-10 16:13 in BASIC Stamp
I have 6 microswitches connected to my robot. Three in the front
and three in the back. How would I write code for these switches.
From the Boe Bot manual I know for two switches connected in front
you can use If (IN5 = 0) AND (IN7 = 0) statement. Im just not sure how to write a program to check for 6 switches.

Comments

  • ltmhallltmhall Posts: 102
    edited 2007-01-10 11:38
    I know how to write code to check for two switches when closed. I’m just not sure how to check for three.
  • stamptrolstamptrol Posts: 1,731
    edited 2007-01-10 12:43
    Its logic!

    If (in5=0) AND (in7=0) AND (in8=0) THEN ......

    You can also use the other logical operators ( OR, XOR, etc )

    While learning this technique, also check out the idea of negative logic which can make OR look like AND !

    Cheers,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
    ·
  • LSBLSB Posts: 175
    edited 2007-01-10 16:13
    Perhaps too:

    http://www.kronosrobotics.com/an155/AAN155.shtml

    A link to multiple switches using only one pin.
Sign In or Register to comment.