Shop OBEX P1 Docs P2 Docs Learn Events
Common code for things like debounce — Parallax Forums

Common code for things like debounce

Bruce KingBruce King Posts: 12
edited 2010-07-21 01:36 in BASIC Stamp
I have not found much code posted on here for common things like debouncing inputs and monitoring inputs over a preset time period.

Can some of you experts post some of your most commonly used·code to help us new guys get·some ideas to save us debug time?·· thanks!·

Comments

  • Martin_HMartin_H Posts: 4,051
    edited 2010-07-21 01:27
    PBASIC has the BUTTON which can be used to read the input state of a switch. Hit F1 in the IDE and you'll see a command reference. BUTTON should be called in a loop and has seven parameters, so the manual will do a better job explaining it than I could here. The BOEbot whisker roaming code likely uses that command which I would think is in the Robots with Boebot book:

    http://www.parallax.com/dl/docs/books/edu/roboticsv2_2.pdf

    Also, the Basic Stamp doesn't have interrupts or background timers. So when I monitor inputs I poll them in the servo pulse loop. In theory if an input changes state faster than your sample time you could miss it. But for physical processes most things happen slow enough that this isn't a problem.

    Post Edited (Martin_H) : 7/21/2010 1:33:37 AM GMT
  • dredre Posts: 106
    edited 2010-07-21 01:36
    Bruce,

    Might this help [noparse][[/noparse] Reply #2 dated 25 Apr 09]:

    http://www.efx-tek.com/php/smf/index.php?topic=1054.0

    cheers, David
Sign In or Register to comment.