Shop OBEX P1 Docs P2 Docs Learn Events
BS2sx Program Help — Parallax Forums

BS2sx Program Help

collegenow09collegenow09 Posts: 3
edited 2008-11-12 22:28 in BASIC Stamp
I wrote a program but want to start it with a push button.· I have it wired to input 6 on the stamp and know i·need·an if...then...else statement.··I want to know if anyone knows how to write a program for this.·

Comments

  • sylvie369sylvie369 Posts: 1,622
    edited 2008-11-12 21:14
    Try a DO...LOOP with an EXIT command, like this one (from the manual):


    DO
      READ eeAddr, char ' get character from DATA statement
      eeAddr = eeAddr + 1 ' update address pointer
      IF (char = 0) THEN EXIT ' if 0, end of string
      DEBUG char ' otherwise, transmit the character
    LOOP ' get next character
    RETURN
    



    Loop back until the button is pressed, as tested in that IF...THEN statement.
  • MSDTechMSDTech Posts: 342
    edited 2008-11-12 22:28
    As an alternative:
    MyButton PIN {whatever pin you have the button on - I'm assuming it will be active High}

    DO Until MyButton=1
    'Add other stuff that may run waiting for the button - but not too much that it can miss the press
    Loop
  • JDJD Posts: 570
    edited 2008-11-12 22:28
    collegenow09,

    There are a few ways to complete this task. Put a pull-down resistor on the button and this will ensure you do not get a false trigger. You can split the code up into two pieces, the first one to watch the button and the second to be the program you jump to. Here is a quick example for your review, this should get your started on the right path.

    :: Example ::

    DO
    ·· IF IN6 = 1 THEN GOSUB MainProgram
    LOOP

    MainProgram:
    ·This is where your program will go
    RETURN


    I hope this helps

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Joshua Donelson

    www.parallax.com
Sign In or Register to comment.