help!! With Keypad change


Closed Thread
Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by clare1
    ....
    The problem with that is the way the example problem works is that
    when the using presses the button, it only activates after you have released the button.
    Question :
    How can i modified the code so that it works when the button is pressed
    the different test1 , test2 & test3 to activate
    would i have to use portb change
    ....

    There is something called "Rising Edge" and also "Falling Edge".

    You check what these are first.

    Then you will know how to set a button when it is pressed or after it is released.

    ----------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  2. #2
    Join Date
    May 2004
    Location
    brighton
    Posts
    149


    Did you find this post helpful? Yes | No

    Cool

    Hi Clare

    Just a thought . For your application you said your were using the LAB-X1 Experimenter Board and that you are only interested in SW1-SW3
    if that is the case you don't even need to use the PortB change interupt
    you can do something like this and it should work give it a go


    Isaac


    ' PicBasic Pro program to show button press on LED

    ' Define LOADER_USED to allow use of the boot loader.

    Define LOADER_USED 1

    OPTION_REG = $7f ' Enable PORTB pull-ups


    loop:
    PORTB = 0 ' PORTB lines low to read buttons
    TRISB = $f0 ' Enable all buttons



    ' Check any button pressed to turn on LED
    If PORTB.4 = 0 Then ' If 4th button pressed...
    pause 50
    if PORTB.4=0 Then
    gosub Earth_Bond
    Endif
    Endif


    If PORTB.5 = 0 Then ' If 3rd button pressed...
    pause 50
    if PORTB.5=0 Then
    gosub Flash_Test
    Endif

    Endif
    If PORTB.6 = 0 Then ' If 2nd button pressed...
    pause 50
    if PORTB.6=0 Then
    gosub IR_Test
    Endif

    Endif

    Goto loop ' Do it forever

    End

    Earth_Bond:
    '==========
    'your stuff here
    return

    Flash_Test:
    '===========
    'your stuff here
    return

    IR_Test:
    '=======
    'your stuff here
    return

Similar Threads

  1. 4x4 keypad Help
    By aaliyah1 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 5th October 2010, 16:34
  2. Keypad input test
    By Kalind in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 8th October 2008, 04:00
  3. Need help in matrix keypad coding
    By rano_zen06 in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 24th May 2008, 13:16
  4. Inconsistent output on a 4x4 matrix keypad
    By markcadcam in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 24th November 2006, 03:54
  5. Keypad unlock (as in garage door possibly)
    By Fred in forum Code Examples
    Replies: 5
    Last Post: - 2nd April 2006, 04:26

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