Shop OBEX P1 Docs P2 Docs Learn Events
programming question for bs2 — Parallax Forums

programming question for bs2

firealarmfreakfirealarmfreak Posts: 105
edited 2008-08-20 20:48 in BASIC Stamp
Hey i have a basic stamp 2 programming question.

I want to loop a section of code for 1 minuite and then have it go to another section of code. How could I do this?

Chris.

Comments

  • FranklinFranklin Posts: 4,747
    edited 2008-08-20 20:43
    you will have to figure out (time) the time it takes to do the loop and then repeat the loop as many times as needed to equal a minute

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Mike GreenMike Green Posts: 23,101
    edited 2008-08-20 20:48
    It helps to use a PAUSE statement to use up most of the loop time (if the loop doesn't do much). For example, you could use 100ms PAUSEs and yet still check switches over a minute like this:
    
    
    cnt = 0 DO
      PAUSE 100
      cnt = cnt + 1
    WHILE IN0 = 0 AND IN1 = 0 AND cnt < 600
    

    The PAUSE occupies most of the loop time, so you may be able to ignore the execution time to keep the count and check the two switches.
    ·
Sign In or Register to comment.