Shop OBEX P1 Docs P2 Docs Learn Events
How would I say this? — Parallax Forums

How would I say this?

bobsmithbobsmith Posts: 36
edited 2004-09-28 22:04 in BASIC Stamp
how do i say

don't activate this code below until the trigger is pulled 3 times then 4th time goes into this code and if trigger doesn't = 1 for more then 1 second repeat the process of pulling trigger 3 times and 4th time equals code below

DO
··· IF Fire = 1 THEN
····· shots = shots + 1
····· HIGH Solenoid
····· PAUSE 10
····· LOW Solenoid
····· PAUSE 40
··· ELSE
····· shots = 0
····· PAUSE 50
··· ENDIF
· LOOP WHILE (shots < 20)
· END

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-09-28 22:04
    That's a pretty tricky request, but I think the code below (you'll have to test it) will do what you requrest.

    Get_Trigger:
    · timer = 0···························· ' manages timing (byte)
    · pulls = 0···························· ' trigger pulls (nib)
    · started = 0·························· ' timing started (bit)
    ··DO
    ··· DO································· ' wait for trigger press
    ····· PAUSE 25························· ' pad loop (affects timer)
    ····· timer = timer + started·········· ' update timer if running
    ····· IF (timer > 40) THEN Get_Trigger· ' restart on timout
    ··· LOOP UNTIL (Trigger = Yes)
    ··· started = 1························ ' start timing
    ··· DO································· ' wait for trigger release
    ····· PAUSE 25························· ' pad loop (affects timer)
    ····· timer = timer + 1·················' update timer
    ····· IF (timer > 40) THEN Get_Trigger· ' restart on timout
    ··· LOOP UNTIL (Trigger = No)
    ··· pulls = pulls + 1·················· ' update trigger pulls
    · LOOP UNTIL (pulls = 4)
    · RETURN

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office


    Post Edited (Jon Williams) : 9/28/2004 10:07:18 PM GMT
Sign In or Register to comment.