Shop OBEX P1 Docs P2 Docs Learn Events
Multiple inputs — Parallax Forums

Multiple inputs

K. ReichmanK. Reichman Posts: 9
edited 2005-11-16 16:59 in BASIC Stamp
How can modify these code to reat eight inputs ??? This code is an example by Parallax.


'
BtnBus VAR INA


'
[noparse][[/noparse] Variables ]

btns VAR Nib
idx VAR Nib


'
[noparse][[/noparse] Program Code ]

Main:
DO
GOSUB Get_Buttons
DEBUG HOME,
"Inputs = ", IBIN4 btns
PAUSE 50
LOOP


'
[noparse][[/noparse] Subroutines ]

Get_Buttons:
btns = %1111
FOR idx = 1 TO 5
btns = btns & ~BtnBus
PAUSE 5
NEXT
RETURN


Tx

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-11-16 16:58
    With the BASIC Stamp, this falls into the "no brainer" category.· Assuming you want to use P0-P7, here's the adjustments:

    BtnBus··· VAR··· INL


    '
    [noparse][[/noparse] Variables ]

    btns····· VAR····Byte
    idx······ VAR··· Nib


    '
    [noparse][[/noparse] Program Code ]

    Main:
    · DO
    ··· GOSUB Get_Buttons
    ··· DEBUG HOME,
    ········· "Inputs = ", IBIN8 btns
    ··· PAUSE 50
    · LOOP


    '
    [noparse][[/noparse] Subroutines ]

    Get_Buttons:
    · btns = %11111111
    ··· FOR idx = 1 TO 5
    ····· btns = btns & ~BtnBus
    ····· PAUSE 5
    ··· NEXT
    · RETURN

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-11-16 16:59
    If the adjustments don't make sense then let me suggest you work through our "What's A Microcontroller?" text -- it's important to know how the Stamp works before trying to implement code on it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.