Timing the pressing and releasing of a PushButton ?


Closed Thread
Results 1 to 5 of 5

Hybrid View

  1. #1
    serandre's Avatar
    serandre Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Melanie
    Code:
    	ButtonPress var GPIO.3
    	Time var Word
    
    	Time=0
    	While ButtonPress=0
    	Time=Time+1
    	Pause 10
    	Wend
    This code will save my project. And so clean and simple... :-)

    Thanks a lot Melanie !

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Just one last comment... if you have a crappy switch subject to bounce, use a larger PAUSE step of say 25 or 50mS and that will eliminate it (personally I tend to use 75 or even 100mS).

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,144


    Did you find this post helpful? Yes | No

    Default

    A note to auto exit after say 500 ms:

    Within the while loop put an If time>500 then exit1

    So the user does not need to hold the button more than the necessary time.

    Ioannis

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