Shop OBEX P1 Docs P2 Docs Learn Events
Please, some help using ‘BUTTON’ command? — Parallax Forums

Please, some help using ‘BUTTON’ command?

AGaugerAGauger Posts: 1
edited 2007-06-26 19:12 in BASIC Stamp
Please, some help using ‘BUTTON’ command?
·
I have successfully implemented the BUTTON command from the example given in the documentation but I’m not familiar enough with the programming language to implement multiple buttons.
I have been using the following code while having a momentary button connected to pin #7:
·
' {$STAMP BS2}
' {$PBASIC 2.5}
Btn PIN 7
btnWrk VAR Byte
Main:
PAUSE 5
BUTTON Btn, 0, 255, 20, btnWrk, 0, No_Press
DEBUG "Button on pin 7 pressed!"
No_Press:
GOTO Main
·
Can someone send me the code to implement a second button where when the momentary button connected to pin 7 is closed the DEBUG message says, “Button on pin 7 pressed!" and when the momentary button connected to pin 8 is closed the DEBUG message says, “Button on pin 8 pressed!”?
·
Any assistance would be greatly appreciated.
Thanks,
~Aaron

Comments

  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2007-06-26 18:49
    Hi Aaron, heres a way to tackle the problem using a loop which I find a little easier to use, but its whichever you prefer.

    DIRS=$0000
    main:
    DO WHILE IN7=0 AND IN8=0

    LOOP
    IF IN7=1 THEN
    DEBUG "7 pressed" ,CR
    ELSEIF IN8=1 THEN
    DEBUG "8 pressed" ,CR
    ENDIF
    PAUSE 500

    GOTO main

    Jeff T.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-06-26 19:12
    Experiment #14 in the Stamp Works Manual covers scanning and debouncing multiple inputs. You can download a free PDF copy of the manual, as well as download source code from the following link. I hope this helps. Take care.

    http://www.parallax.com/detail.asp?product_id=27220

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
Sign In or Register to comment.