keypad 4x3


Closed Thread
Results 1 to 17 of 17

Thread: keypad 4x3

  1. #1
    Join Date
    Feb 2006
    Location
    france
    Posts
    47

    Default keypad 4x3

    Hello


    Currently I use the program by Bruce, a 4x3 keypad and wire
    this way:
    RB6 RB5 RB4
    RBO 1 2 3
    RB1 4 5 6
    RB2 7 8 9
    RB3 * # 0

    But when I visualize the data received on my computer, the figures are
    step in the right order.

    An example:

    RB0 RB7 4
    RB0 RB6 3
    RB0 RB5 2
    RB0 RB4 1

    I do not know how, thank you for your help
    Attached Images Attached Images    
    Attached Files Attached Files

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by jonas2 View Post
    ...and wire
    this way:
    RB6 RB5 RB4
    RBO 1 2 3
    RB1 4 5 6
    RB2 7 8 9
    RB3 * # 0
    RB7 not used here . . .
    But when I visualize the data received on my computer, the figures are
    step in the right order.

    An example:

    RB0 RB7 4
    RB0 RB6 3
    RB0 RB5 2
    RB0 RB4 1
    But it is used in this example . . . . BTW Hi Jonas2 . . .

    I do not know how, thank you for your help
    OK, What is it you do not know how to do ?
    The "little secret" of this code is when it scans the keypad each button = a number from zero to 12 or 16 depending upon which keypad you use, and the lookup table then makes it have the number <b>YOU</b> want those keys to represent.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    Join Date
    Feb 2006
    Location
    france
    Posts
    47


    Did you find this post helpful? Yes | No

    Default keypad

    Hello

    Even with instruction lockup figures are reversed.
    RB7 on I put a led, for columns RB6 RB5 RB4 for
    lines rb0 RB1 RB2 RB3.

    I really do not understand this program and how to edit?

  4. #4
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default

    This is the line to edit

    LOOKUP Key,["147*2580369#"],sKey

    But it looks like you have you rows and columns wired wrong. Swap your RB4 and RB6 wires over.

    Steve

  5. #5
    Join Date
    Feb 2006
    Location
    france
    Posts
    47


    Did you find this post helpful? Yes | No

    Default keypad

    hello

    I already tested this way, but without success.

    .......RB6... RB5... RB4

    RB0... 1... 2 ... 3

    RB1... 4 ... 5... 6

    RB2... 7... 8 ... 9

    RB3... * ... 0 ... #

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default

    If you won't post your code I think it is difficult to get help...

    Ioannis

  7. #7
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default

    This is becoming very confusing. For a 4x3 keypad RB0 to RB6 should be used RB7 is not used. So why are you talking about RB7 of course if you are using a 4x4 keypad you would use all of the pins.

    Can you send a photograph of your set up?

    Steve

  8. #8
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by jonas2 View Post
    RB7 on I put a led, for columns RB6 RB5 RB4 for
    lines rb0 RB1 RB2 RB3.
    OK, I think your problem is here, you set the TrisB to $F0 which in binary is 11110000, which sets the lower ports as outputs and the upper ports as inputs, so then you hang an LED on this PortB.7 input and it pulls it low. Change the Tris To $70 or %01110000, which will set the PortB.7 as an output. Better yet, put it back the way Bruce wrote it and move the LED to PortA otherwise, (although I am not sure), I think the keypad will not go over 7, I think if you want to "rob" portB of a port you must use one of the outputs not inputs.
    Last edited by Archangel; - 10th July 2009 at 08:11.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  9. #9
    Join Date
    Feb 2006
    Location
    france
    Posts
    47


    Did you find this post helpful? Yes | No

    Default keypad

    Hello

    Thank you for your help, I change this way:
    getkeyp:'----------------------------------------- Wait for keypress
    FOR row = 0 TO 3 ' 4 rows in keypad
    PORTB = 0 ' All output-pins low
    TRISB = (DCD row) ^ $ff ' Set one row pin to output
    col = PORTB >> 3 ' Read columns
    IF col != $f THEN gotkey ' If any keydown, exit
    NEXT row
    GOTO getkeyp ' No keys down, go look again

    gotkey: ' Change row and column to key number 1 – 16

    key = (row * 3) + (NCD (col ^ $8f))




    '------RB6--RB5--RB4--
    ' | | |
    'RB0----1----2----3---row1
    ' | | |
    'RB1----4----5----6---row2
    ' | | |
    'RB2----7----8----9---row3
    ' | | |
    'RB3----*----0----#---row4
    ' | | |
    '-----col1--col2--col3


    LOOKUP key,["1","4","7","*","2","5","8","0","3","6","9","# "],skey

    LOOKUP key,["147*2580369#"],skey


    '8f = %10001111 = LED,col1,col2,col3,row4,row3,row2,row1


    @ DEVICE pic16F628, INTRC_OSC_NOCLKOUT
    @ DEVICE pic16F628, WDT_ON
    @ DEVICE pic16F628, PWRT_OFF
    @ DEVICE pic16F628, BOD_ON
    @ DEVICE pic16F628, MCLR_ON
    @ DEVICE pic16F628, LVP_OFF
    @ DEVICE pic16F628, CPD_OFF
    @ DEVICE pic16F628, PROTECT_OFF


    Include "modedefs.bas"
    DEFINE OSC 4

    col VAR BYTE ' Keypad column
    row VAR BYTE ' Keypad row
    key VAR BYTE ' Key value
    i var byte
    led var PortB.7
    serpin VAR PortA.3 ' Serial output pin
    CMCON = 7 ' PortA = digital I/O
    VRCON = 0 ' Voltage reference disabled
    OPTION_REG.7 = 0 ' Enable PORTB pull-ups

    loop:
    GOSUB getkey ' Get key from keypad
    SEROUT2 serpin,84,[skey,10,13] ' Send key value out PortA.3
    GOTO loop

    getkey:
    high led
    PAUSE 50 ' Debounce key-input

    getkeyu:'----------------------------------------- Wait for all keys up

    PORTB = 0 ' All output-pins low
    TRISB = $f0 ' Bottom 4-pins out, top 4-pins in 1111 0000
    IF ((PORTB >> 4) != $f) THEN getkeyu ' If keys down, loop
    PAUSE 50 ' Debounce key-input

    getkeyp:'----------------------------------------- Wait for keypress

    FOR row = 0 TO 3 ' 4 rows in keypad
    PORTB = 0 ' All output-pins low
    TRISB = (DCD row) ^ $ff ' Set one row pin to output
    col = PORTB >> 4 ' Read columns
    IF col != $f THEN gotkey ' If any keydown, exit
    NEXT row
    GOTO getkeyp ' No keys down, go look again

    gotkey: ' Change row and column to key number 1 - 16
    key = (row * 3) + (NCD (col ^ $f))
    LOOKUP Key,["147*2580369#"],sKey ' 1 4 7 * 2 5 8 0 3 6 9 #
    'LOOKUP Key,["*","7","4","1","0","8","5","2","#","9","6","3 "],sKey
    PAUSE 50
    low led
    RETURN ' Subroutine over

    END

  10. #10
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default

    Jonas2

    And it still does not work?

  11. #11
    Join Date
    Feb 2006
    Location
    france
    Posts
    47


    Did you find this post helpful? Yes | No

    Default keypad

    not yet, and the keys are shifted

  12. #12
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default

    You are using pull up resistors for the inputs so col will be 1111 when no key pressed. If you press number 1 then it will be 1011 so at ****2 1011 xor 1111 will become 0100 and key=(0*3)+(NCD(0100))

    which is 3 and on your lookup the third number is 7 so change the 7 to 1 and that one will be correct.

    If you wire

    '------RB4--RB5--RB6--
    ' | | |
    'RB0----1----2----3---row1
    ' | | |
    'RB1----4----5----6---row2
    ' | | |
    'RB2----7----8----9---row3
    ' | | |
    'RB3----*----0----#---row4
    ' | | |
    '-----col1--col2--col3

    then

    the lookup table is

    LOOKUP key,["123456789*0#"],skey which is a bit neater.

    If you press number 1 then it will be 1110 so at ***2 1110 xor 1111 will become 0001 and key=(0*3)+(NCD(0001))which is 1 and on your lookup the first number is 1 so that one is correct.


    Lets try again with number 8 now we have 1101 which becomes 0010 and key=(2*3)+(NCD(0010))which is 8 and on your lookup the eighth number is 8that one is correct.

    so these are the changes to make

    col = PORTB >> 4 ' Read columns ****** ************** 1
    IF col != $f THEN gotkey ' If any keydown, exit
    NEXT row
    GOTO getkeyp ' No keys down, go look again

    gotkey: ' Change row and column to key number 1 – 16

    key = (row * 3) + (NCD (col ^ $f)) ******************** 2




    '------RB4--RB5--RB6--
    ' | | |
    'RB0----1----2----3---row1
    ' | | |
    'RB1----4----5----6---row2
    ' | | |
    'RB2----7----8----9---row3
    ' | | |
    'RB3----*----0----#---row4
    ' | | |
    '-----col1--col2--col3


    'LOOKUP key,["1","4","7","*","2","5","8","0","3","6","9","# "],skey

    LOOKUP key,["123456789*0#"],skey ******************** 3

    Do you understand the maths and logic now? XOR always intrigued me along with bitwise operators. Why did anyone even think of this was my first thought. After a while I have found them useful.

    Steve

  13. #13
    Join Date
    Feb 2006
    Location
    france
    Posts
    47


    Did you find this post helpful? Yes | No

    Default keypad

    Hello

    I still have not solved my problem, I tried different configuration
    and impossible to get what I want?

    Do you have other examples of management programs 4x3 keypad.

    Thank you
    Attached Files Attached Files

  14. #14
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Do you have other examples of management programs 4x3 keypad.
    Why don't you use the universal keypad project? See it @ http://www.picbasic.co.uk/forum/showthread.php?t=10420

    Al.
    All progress began with an idea

  15. #15
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default

    In your program you have the rows and columns the wrong way round and also can we resolve wether it is a 3x4 or 4x4 keypad because in your program you have 16 digits in your lookup table.

    It looks to me as if you have not read my last post?

    Steve

  16. #16
    Join Date
    Feb 2006
    Location
    france
    Posts
    47


    Did you find this post helpful? Yes | No

    Default keypad

    Hello EarlyBird2

    Thank you for your help and it works well.
    Attached Images Attached Images  

  17. #17
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default

    You are most welcome.

    Steve

Similar Threads

  1. 4x4 keypad Help
    By aaliyah1 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 5th October 2010, 16:34
  2. 4x3 keypad and an LCD.. need help.
    By taisen83 in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 6th January 2009, 09:34
  3. Keypad input test
    By Kalind in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 8th October 2008, 04:00
  4. Need help in matrix keypad coding
    By rano_zen06 in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 24th May 2008, 13:16
  5. 4x3 keypad
    By docwisdom in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 16th April 2006, 08:50

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