Shop OBEX P1 Docs P2 Docs Learn Events
Expanding Inputs from "StampWorks" — Parallax Forums

Expanding Inputs from "StampWorks"

TonyATonyA Posts: 226
edited 2005-10-23 14:58 in BASIC Stamp
Hi,

I am reading the "Experiment #24b: Expanding Inputs" from "StampWorks', using the shift registers.

I'm having a problem understanding how the program will determine the state of each individual switch. Does it just determine whether any switch is on or off, or does the program determine the state of each individual switch?

I need something like this:

If switch #1 is on then serout [noparse][[/noparse]this]
If switch #2 is on then serout [noparse][[/noparse]that]
etc. (for 24 sensors, so I will need 3 shift reg. IC's)

Thanks for any suggestions.

Tony A

Post Edited (TonyA) : 10/23/2005 1:34:47 PM GMT

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-10-23 14:55
    Remember that every variable in PBASIC is bit-addressable, so you can do something like this after you read a·value back from the 74HC165:

    · IF (status1.BIT0 = 1) THEN
    ··· SEROUT TX, Baud, [noparse][[/noparse]"Button 1 pressed", CR]
    · ENDIF

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • TonyATonyA Posts: 226
    edited 2005-10-23 14:58
    Very cool, thanks.

    Tony A
Sign In or Register to comment.