Single button function


Results 1 to 40 of 41

Threaded View

  1. #11
    Join Date
    Jun 2005
    Location
    Wisconsin
    Posts
    382


    Did you find this post helpful? Yes | No

    Lightbulb Finally got it!

    After working on this for some time I have come up with a routine that does what I need it to do. I may use Timer1 to keep track of how long the button is held in place of PAUSE, but it works as is.

    There are three button states 0, 1, 2:
    0=no action
    1=short press/release
    2=Held


    Switch_Routine:
    ButtonState=0
    IF Switch=1 Then ButtonCnt=0

    IF Switch=0 Then
    While Switch=0
    Pause 250
    ButtonCnt=ButtonCnt+1

    IF ButtonCnt=ButtonHeld Then
    ButtonState=2
    Return
    EndIF
    Wend

    IF ButtonCnt<ButtonHeld Then ButtonState=1
    EndIF
    Return
    Last edited by DynamoBen; - 12th August 2006 at 18:44.

Similar Threads

  1. Sony SIRC IR Issue
    By Ryan7777 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 8th August 2015, 08:10
  2. 3 HPWM channels
    By docwisdom in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 4th April 2006, 02:43
  3. Code check -- button not working
    By docwisdom in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 2nd March 2006, 22:43
  4. Pushbutton code routine suggestions?
    By jessey in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd September 2005, 01:02
  5. Button subfunction 16F628
    By Jųan in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 19th August 2005, 16:44

Members who have read this thread : 1

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