Matrix Keypad routine


Results 1 to 40 of 135

Threaded View

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


    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.

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