Shop OBEX P1 Docs P2 Docs Learn Events
Continuous Loop — Parallax Forums

Continuous Loop

fzeitgeistfzeitgeist Posts: 20
edited 2005-04-14 19:09 in BASIC Stamp
Hi Everyone. I am trying to run a continuous loop unless some one presses a key on a keypad.

Lets say I am moving a motor for 49 seconds. If someone presses a key within those 49 secs. the motor stops, otherwise it should go to a different subroutine after completing the 49 secs. cycle.

I tried using the SERIN command with {Timeout,Tlabel,} syntax but it does'nt seem to work.
Here is what I have

wait_for_key:

SERIN Rx, Baud, 49000, continue , [noparse][[/noparse]temp]
return


'' 49000 seconds = Timeout
'' continue == go to this subroutine if no key pressed

Comments

  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-04-14 18:14
    I think that the·BUTTON command is a better fit for your application than SERIN, but you will need to implement your own timeout function.
  • NewzedNewzed Posts: 2,503
    edited 2005-04-14 19:09
    You didn't show the code for running the motor, but let's assume it is something like this:

    HIGH 0········· 'turns motor on
    for x = 1 to 98
    pause 500
    IF·in1 = 0·THEN quit
    next
    GOTO next task

    quit:
    LOW 0
    'do something else

    The for/next loop will run the motor for 49 seconds - 98 x 500.

    If Pin 1 is taken low the motor stops.· Resonse to the LOW pin 1 will be .5 seconds.· If that is not quick enough change the for/next loop to 196/250.· Then it will respond in .25 seconds.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    NEW! 4 MB EEPROM

    http://hometown.aol.com/newzed/page4.html
    ·
Sign In or Register to comment.