keypad 4x3


Closed Thread
Results 1 to 17 of 17

Thread: keypad 4x3

Hybrid View

  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
    4,115


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

  8. #8
    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

  9. #9
    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?

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