debouncing switches with a timer interrupt?


Results 1 to 28 of 28

Threaded View

  1. #10
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Counter Var Byte

    RB_MainMenuLoop:
    ' BTN_PLUS is the Next Choice button

    PAUSE 1

    IF BTN_PLUS=0 THEN

    IF FLAG_PLUS = 0 THEN
    bMenuPos = bMenuPos + 1
    FLAG_PLUS = 1
    Counter = 0
    ENDIF

    ELSE
    Pause = 10
    Counter = Counter + 1
    IF Counter > 50 THEN FLAG_PLUS = 0 : Counter = 0
    ENDIF

    IF bMenuPos>22 THEN
    bMenuPos=1
    ENDIF

    Goto DisplayMainMenuLoop:

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

    Try this snippet and see how it works. You can tune the PAUSE 10 and Counter > 5, to better values to suite your need.

    Al.
    Last edited by aratti; - 30th July 2010 at 08:48.
    All progress began with an idea

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts