Matrix Keypad routine


Closed Thread
Results 1 to 40 of 135

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default

    Yes, that is correct. Rest applies of course.

    But don't be afraid of the word variable!

    Ioannis

  2. #2


    Did you find this post helpful? Yes | No

    Default help with a small change

    Hi all

    The keypad code has been working very well ! Thanks mister_e!

    Initially I had to wire alter the wiring to the keypad to the PIC to get things working now in order to match the header pins for PORT B on a dev board I am building I need to alter the include file somehow to match my keypad.
    I was hoping someone could point me in the right direction for this or tell me where to change the code to match the desired pin configuration.
    Here is what I have now:

    EXISTING CONFIG (WORKING)
    -------------------------

    Columns Rows
    ______________ _____________
    Keypad 7 6 5 4 3 2 1 0

    PIC B4 B5 B6 B7 B0 B1 B2 B3

    Here's what I would like to be
    DESIRED CONFIG
    --------------

    Columns Rows
    ______________ _____________
    Keypad 7 6 5 4 3 2 1 0

    PIC B7 B6 B5 B4 B3 B2 B1 B0



    I would appreciate any help/info

    Kind regards

    Dennis
    Last edited by Dennis; - 7th January 2010 at 23:34.

  3. #3


    Did you find this post helpful? Yes | No

    Default Here's a picture to better explain it

    Check the attached file

    Dennis
    Attached Images Attached Images  

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Steve's keypad routines won't let you reverse the orders like that.
    But you can re-map the keys to whatever you want.

    By reversing both the columns and rows, I think it would come out like this ...
    Code:
    @ READKEYPAD _myvar
    
    ; original keys   1  2  3  4  5  6  7 8 9 10 11 12 13 14 15 16 
    LOOKUP  myvar,[0,16,15,14,13,12,11,10,9,8, 7, 6, 5, 4, 3, 2, 1],myvar
    Which should also work like this ...
    Code:
    myvar = 17 - myvar
    If they don't line up right, you can change the LOOKUP to a pattern that matches.

    hth,
    DT

  5. #5


    Did you find this post helpful? Yes | No

    Default awesome

    Thanks Darrel

    Will give it a shot and feedback results here :-)

    Dennis

  6. #6


    Did you find this post helpful? Yes | No

    Default Fixed!!

    Hi Darrel

    Thanks for the assistance :-)
    The LOOKUP change was the easiest solution !

    originally I had this
    Code:
    @ READKEYPAD _myvar  'read keypress variable and place in myvar
    
    LOOKUP myvar,[0,"123A456B789C*0#D"],myvar 'use lookup table to diplay proper keypress
    And I just changed the line to this
    Code:
    @ READKEYPAD _myvar  'read keypress variable and place in myvar
       LOOKUP myvar,[0,"D#0*C987B654A321"],myvar
    Thanks a million , it saves me having to redo my dev board design or re-wiring the keypad :-) YAY

    Kind regards
    Dennis

  7. #7
    Join Date
    Feb 2008
    Location
    Michigan, USA
    Posts
    231


    Did you find this post helpful? Yes | No

    Default Fail enought times and you start to learn!

    HI all,
    I have been playing with this wonderful piece of code for many hours. Really cool code. I was having problems with one row of the keypad but the rest was working enough for me to proceed filling in the gaps and learning the lessons from the thread. I bring this up because I have been caught on it before, you would have thought I'd have learned....

    The row in question would freeze the operation of the circuit. Upon looking closely at the datasheet, I my eye caught the LOW VOLTAGE PROGRAMMING option. A faint voice in my head reminded me that we were not friends (the option, not the voice). Yep, that was it. Disabled it in meLabs programmer and... you guessed it... runs just like it was suppose to. Who'd a thought it?

    Hope that this saves someone else some head banging. Some gotchas I have to keep reminding myself about.
    Bo

Similar Threads

  1. calculator-like code entry with matrix keypad and display
    By Dennis in forum mel PIC BASIC Pro
    Replies: 35
    Last Post: - 16th December 2009, 22:58
  2. Need help in matrix keypad coding
    By rano_zen06 in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 24th May 2008, 13:16
  3. I2C PCF8574 4X4 Keypad routine
    By RFsolution in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th January 2007, 21:25
  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. very basic matrix keypad question
    By kitcat in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 8th July 2006, 21:33

Members who have read this thread : 2

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