Button command question


Results 1 to 10 of 10

Threaded View

  1. #8
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink With 2 buttons now ...

    For twin Button press ...

    just add another scan loop ...

    Code:
    
    SCAN:
    
    RESULT = 0 
    
    FOR I = 0 to 4 
    
       BVar = 0
    
       BUTTON PORTB.0[I],0,255,0,BVar,1,Action
    
    NEXT I
    
    GOTO SCAN                                             ' No need to go further ...
    
    Action :
    
          RESULT.I = 1                                     ' Store the first button pushed
          
          PAUSE 250                                         ' Let a little time for pushing the
                                                                  ' next button ...
          FOR J= 0 to 4
     
          IF J = I THEN I = I+1                            ' Button already pushed !!! ... Skip test.
      
          BVar = 0
    
         BUTTON PORTB.0[I],0,255,0,BVar,1,Action2
    
         NEXT J
    
         GOTO Action1                                       ' Only one button Pushed  ... 
    
         
    Action2:
    
    RESULT.J = 1                                              ' Store the second button pushed
    
    Action1:
    
    SELECT CASE RESULT
    
        CASE %00000001                      ' Button 0 alone
        ...
        CASE %00000010                      ' Button 1 Alone
        ...
        CASE %00000100                      ' Button 2 Alone
        ...
        ...
        ...
        CASE %00000011                      ' Buttons 0 and 1 ... or  1 and 0
        ...
        CASE %00000101                      ' Buttons 0 and 2 ... or  2 and 0
        ...
        ...
        ...
        CASE %00000110                      ' Buttons 1 and 2 ... or  2 and 1
        ...
        CASE %00001010                      ' Buttons 1 and 3 ... or  3 and 1
        ...
        ...
        ...
        CASE %00001100                     ' Buttons 2 and 3 ... or  3 and 2
        ...
        CASE %00010100                     ' Buttons 2 and 4 ... or  4 and 2
       
        CASE ELSE  GOTO SCAN
    
    END SELECT
    with 16 bits for RESULT, RESULT.Highbyte for I, RESULT.Lowbyte for J, .... you can even check in which order the buttons have been pushed ...

    Too much ??? Ok, I take it back to my kangaroo pocket ...

    Alain
    Last edited by Acetronics2; - 30th August 2009 at 13:38.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

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. Button Push within 3 second Window
    By Tissy in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 22nd December 2005, 10:06
  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 : 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