Shop OBEX P1 Docs P2 Docs Learn Events
how do you count... — Parallax Forums

how do you count...

ERMERM Posts: 34
edited 2005-07-27 22:54 in BASIC Stamp
Can you use the button command to count the length of time for a button being pressed?· I want to be able to count when a button is pressed for 3 seconds.· Is this possible?

Comments

  • pBASICpBASIC Posts: 25
    edited 2005-07-27 20:42
    how do you use debug with this i want to use debug to write what timer is at thAt time when the button is held

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    =============================================================================================================================================
    Name=Chris

    =============

    Age

    12

    ======
    grade

    7

    Webpage
    Email=miniwarrior@cox.net
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-07-27 21:04
    Insert

    · DEBUG DEC timer, CR

    ... where you want to see the timer value.· Note that if you put this in the loop you will affect the loop timing (slow it down a·bit)·as DEBUG takes time to operate.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • pBASICpBASIC Posts: 25
    edited 2005-07-27 22:09
    Thanks

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    =============================================================================================================================================
    Name=Chris

    =============

    Age

    12

    ======
    grade

    7

    Webpage
    Email=miniwarrior@cox.net
  • pBASICpBASIC Posts: 25
    edited 2005-07-27 22:14
    mines Better

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    StartBtn PIN 3
    timer VAR Byte
    minute VAR Byte
    minute = 60
    Main:
    DO : LOOP UNTIL (StartBtn = 1)
    PAUSE 1050
    timer = timer + 1
    DEBUG CLS
    DEBUG ? timer
    IF timer = 60 THEN GOTO subtract
    GOTO main
    subtract:
    timer = timer - minute
    GOTO main

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    =============================================================================================================================================
    Name=Chris

    =============

    Age

    12

    ======
    grade

    7

    Webpage
    Email=miniwarrior@cox.net
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-07-27 22:54
    Better than what? Clearly you misunderstand that adding DEBUG to the loop increases the loop timing instead of decreasing it as your PAUSE 1050 loop delay would indicate.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.