Shop OBEX P1 Docs P2 Docs Learn Events
Timer — Parallax Forums

Timer

ThumbsThumbs Posts: 2
edited 2005-09-14 00:34 in BASIC Stamp
I am using the loop function on the bs2 for a timer( t = t+1) and would like to capture a·lap time by presing a button while the timer is still running . Is this possible?
thanks.

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-09-13 04:51
    Thumbs,

    ·· Not sure how accurate your timer will be, but in your loop you can do an IF...THEN to determine if the button is pressed.· For example, if it's active low, you could use:

    IF IN0 = 0 THEN
    ·· ' SAVE LAP TIME?
    ENDIF

    inside your loop...Depending on the speed of your loop you may need to add exclusion to the IF statement so it only executes once.· It would help to see the code you're using for the loop/timer.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • japerjaper Posts: 105
    edited 2005-09-13 19:25
    you could assign a varible to your push button action
    and then in the subroutine
    write to data to recall later
    that way your timer routine will loop and you would loose time throught the
    write execution
  • japerjaper Posts: 105
    edited 2005-09-14 00:34
    heres the code i used to beat the processor at it's own game

    Get_InputSignal:
    Debug CLS, ? InputSignal
    Pause DelayReader
    Write 7 , InputSignal
    Return

    this way you can hit the button and keep your loop going ,
    this was used to get the state of pin #7 but you get the idea
    you will still loose time
    not far advanced yet to Calc_ loss of time with an algorithm but do able
Sign In or Register to comment.