Matrix Keypad routine


Closed Thread
Results 1 to 40 of 135

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    An idea would be to use the lookup command for your translation from numbers to numbers-ASCII conversion.

    Now about the numbers to assebly in a byte. What is the range of your input?

    0-255 or 0-999?

    Ioannis

  2. #2


    Did you find this post helpful? Yes | No

    Default

    Hi Ioannis

    Thanks for the reply :-)
    Lookup is already implemented and working .

    My range would be anything really (inifinity ??) but I guess I could use 0 to 999

    It's like dialling on a phone ... you dial the numbers and then press the dial button :-)

    I want to type numbers in and then press the # key and * to backspace or clear last entry ...

    Kind regards

    Dennis

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,139


    Did you find this post helpful? Yes | No

    Default

    Well, if you go for the 999 then a 0-65535 is possible as the final result needs a word variable.

    One idea untested is this:

    Code:
    array   var byte[5]
    index   var byte
    i       var byte
    word_v  var word
    
    'Get keypress
    index=0
    
    loop:
    gosub key_read
    if mykey=32 then loop 'No key press returns 32
    array[index]=myvar
    index=index+1
    if index=5 then calculate_result
    goto loop
    ...
    
    caculate_result:
    word_var=0:mult=10000
    for i=index-1 to 0 step -1
        word_var=word_var*mult+array[i]
        mult=mult/10
    next i
    index=0
    goto display_result
    As there is the index counter, there is no need to press '#'. Numbers must be entered in 5 digit format, e.g. 00123.

    Also there is no filter if the user keys in a number greater than 65535, in which case result will be of course wrong due to overflow.

    Ioannis
    Last edited by Ioannis; - 23rd November 2009 at 21:02.

  4. #4


    Did you find this post helpful? Yes | No

    Default ooops

    Hi Ioannis

    Thank you for the code example... I'm just thinking that perhaps it would indeed be more practical to use 255 as the max number, in which case I would need to declare a byte as opposed to a word ...not so ?

    Kind regards

    Dennis

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,139


    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

  6. #6


    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.

  7. #7


    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  

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 : 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