Button press and press & hold how to ?


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    44


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by weirdjim View Post
    I'm a real newbie at the PIC, but my BASIC is fairly decent. What is the reason for the GOTO InputButton command at the end of the FOR-NEXT loop? The button will be either zero (in which case you GOTO Stp) or one (in which case you GOTO Prk). How would the code ever get to that GOTO InputButton command? Or is that a belt-and-suspenders command on the off chance that the button is released during the last millisecond of the loop?

    Somebody said something about switch debounce. Is there a standard debounce code snippet for pushbutton switches? A 50 millisecond delay waiting for the sucker to stop clanging around?

    Jim
    1. GOTO InputButton is for start at the beginning after the button was detected as pressed. Going to Loop the program
    2. If the button was released before the timer ends at 1 second means -> short press of the button.
    3. ELSE long press of button.
    4. Insert a pause of 20ms -50ms. My best results measured with 20ms for Button debounce.
    If you have a complex matrix of columns and rows with double action feature like this, your code will slow down. I also prefer to use for next loops with Pause 1, while time critical projects and Interrupt routines.
    If you insert
    PAUSE 2000 is it impossible to jump to the Interrupt routine, when your pause is active.

    Delay2: ' Now it´s possible to interrupt during the PAUSE and jump to your Interrupt location
    FOR x = 0 TO 1000
    PAUSE 1
    NEXT x
    RETURN

    I mean that are my techniques, everyone should code like he likes it.

  2. #2
    Join Date
    Jul 2007
    Posts
    53


    Did you find this post helpful? Yes | No

    Smile I'm learning something here

    Hi Robson,

    you said: "PAUSE 20 ' Button delay or use DEFINE BUTTON_PAUSE before"

    I tought before that DEFINE BUTTON_PAUSE was used only by the BUTTON command. Now, from what you wrote is that correct to say that BUTTON_PAUSE will put a debounce delay on all PIC inputs pins?

    J-P

Similar Threads

  1. 4 Bytes one button press
    By Dennis in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 15th January 2010, 22:36
  2. Giving power to MCU upon button press - Good Idea?
    By financecatalyst in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 21st July 2009, 07:34
  3. multi functions button press
    By malwww in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 27th May 2009, 00:12
  4. Using Sleep
    By elec_mech in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 17th August 2008, 04:05
  5. Sleep until button press?
    By kevj in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 9th October 2007, 03:47

Members who have read this thread : 2

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