Shop OBEX P1 Docs P2 Docs Learn Events
Newbie in need of help — Parallax Forums

Newbie in need of help

Catch22Catch22 Posts: 1
edited 2005-05-02 03:14 in BASIC Stamp
Hey. For my school project I have two buttons hooked up as in the servo control example in page 129 of What's a Microcontroller (active-high). Im tryin to set it up so the first button initiates the program.. and the other may pause it either between subs or immediately, if possible. I do not know how to make the BASIC2 board "wait" and respond to the second button. The only thing that is mentioned in the documents that I recieved with my Board of Education vC is on page 301- POLLIN but it says it's only for BS2p and BS2pe.

What are my options?

Here is my main function:
Main:
· BUTTON 3,1,255,0,btnWrk,0,Main· 'restarts the program unless button3 is pressed
··· DEBUG HOME, "Running Cycle", CR
··· BUTTON 4, 1, 255, 0,btnWrk,1, Freeze
··· GOSUB Scoop
···· BUTTON 4, 1, 255, 0,btnWrk,1, Freeze
··· GOSUB FeedServe
··· BUTTON 4, 1, 255, 0,btnWrk,1, Freeze
··· PAUSE 1000
··· GOSUB FeedRetract
····· IF(IN3 = 0 AND IN4 = 1) THEN
····· GOSUB Freeze
····· ENDIF
·DEBUG "done"
END

The only real way of making this stop is to hold the pin-4 button.. but I want something a little more elegent..


htank you very much!
tom

Comments

  • BeanBean Posts: 8,129
    edited 2005-05-02 01:49
    Tom,
    Each button in any loop must have it own seperate btnWrk variable.
    Not sure if that is what's causing your problem though...
    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "SX-Video Display Module" Available Now.

    www.sxvm.com

    "I thought I was wrong once...But I was mistaken [noparse];)[/noparse]"
    ·
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-05-02 03:14
    StampWorks shows how to scan and debounce multiple buttons. It's easier to deal with than the BUTTTON function, which is always a bit of a trick to use.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
Sign In or Register to comment.