will this work for dedecting a held button?


Results 1 to 6 of 6

Threaded View

  1. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Ming thuang bing daaang zing YIIIHHHAAA
    Code:
        ' PIC12f629
        ' Push-button attach to GPIO<3:0> between i/o and VCC
        '
        ' it assume you'd previously disable all analog stuff and MCLR pin    
        '
        aPushButton var byte
        PushButton  var byte
        Delay       var Word
        
    Start:
          clear
          apushbutton=GPIO & $0F      ' read push-button
                                      ' keep only GPIO<3:0> bits
                                      '
          if apushbutton=0 then start ' no push button pressed, sit and spin
          pushbutton=apushbutton
          while (apushbutton!=0) 
                 apushbutton=GPIO & $0F
                 pause 10
                 delay=delay+1
                 wend
                 
          pause 50 ' debounce delay       
          if DELAY<100 then ' if push button is press for less than 1 second
             Select case PushButton
                    case 1
                         gosub PushButtonGPIO_0
                    case 2
                         gosub PushButtonGPIO_1
                    case 4
                         gosub PushButtonGPIO_2
                    case 8
                         gosub PushButtonGPIO_3
                    end select
             endif
          goto start
    The above should work. There's probably tons of different way to do it but, this is the first interrupt/Assembler/InternalRegister adressing free comming example.
    Last edited by mister_e; - 13th November 2005 at 20:22.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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. Interruptus Frustratus
    By Byte_Butcher in forum General
    Replies: 16
    Last Post: - 17th April 2009, 20:36
  3. 3 HPWM channels
    By docwisdom in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 4th April 2006, 02:43
  4. Code check -- button not working
    By docwisdom in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 2nd March 2006, 22:43
  5. Button Push within 3 second Window
    By Tissy in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 22nd December 2005, 10:06

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