---
+ Post New Thread
Results 1 to 18 of 18
  1. #1
    Full Member level 5
    Points: 3,731, Level: 14
    asic1984's Avatar
    Join Date
    Nov 2003
    Posts
    259
    Helped
    4 / 4
    Points
    3,731
    Level
    14

    How to read inputs from 4*4 hexadecimal keypad?

    hi all

    how to read inputs from 4*4 hexadecimal keypad.........

    thanks for help

    •   Alt17th November 2004, 16:39

      advertising

        
       

  2. #2
    Full Member level 2
    Points: 2,269, Level: 11

    Join Date
    Mar 2004
    Posts
    121
    Helped
    17 / 17
    Points
    2,269
    Level
    11

    interfacing keypad

    You can choose one of two methods:

    - keyboard scan
    - interrupt program

    If your project is not too complex, the first method is better (easily understand and implement).
    If your project requires to save your I/O ports (save your address space), the second one is better. In this case you should study how to write an interrupt procedure.

    good luck,



  3. #3
    Advanced Member level 2
    Points: 21,612, Level: 35

    Join Date
    Sep 2004
    Posts
    662
    Helped
    72 / 72
    Points
    21,612
    Level
    35

    interfacing a keypad

    Pls see whether the following articles will help or not:


    Keypad Interface Code
    http://www.ee.ualberta.ca/~elliott/e...Ed/keypad.html



    Quote Originally Posted by From an article
    Software Interface
    In this section, we will show how the scan code is generated using a Software Interface. As stated before, the keyboard switches are arranged in a matrix of rows and columns. To show how a scan code can be generated using a software interface we shall take, as an example, the hexadecimal keypad.


    Circuit Description
    * The keypad Switches are connected in a matrix of rows and columns :
    -The rows of the matrix are connected to four output port lines.
    -The columns of the matrix are connected to four input port lines.
    -For simplicity, the rows of the matrix are connected to four input lines.

    * When no key is pressed, the column lines are high.

    * When a key is pressed, it connects a row to a column.

    * If a row is at low and a key in that row is pressed, this low will appear on the column that contains the pressed key and it can be detected on the input port.

    * If we can determine the row and column of a key, then we can determine which key it is and so we can assign to it an ASCII code.


    Algorithm Description
    The following Algorithm shows how to determine the row and column of a key and generate its Scan code:

    1-Step One : Output Zero’s to all rows.

    2-Step Two : This step consists of a Loop in which we read columns over and over until the columns are all high. We do this to make sure that the previous key has been released before we look for the next one. This is called Two-key lockout.

    3-Step Three : Upon exit from Step Two, control goes to this step which is also a Loop. This loop reads columns over and over until one column is low which indicates that a key has been pressed.

    4-Step Four : Upon exit from the previous loop, a check is done to avoid the effect of noise. During this stage, columns are read so that if they are high again, this means that the low detected in the step Three was caused by a noise rather than a key press. In this case, control goes back to step Two otherwise step Five is executed.

    5-Step Five: Once we reach this step, we need to determine the row and column of the pressed key. This is done in this step which is also a LOOP. In this loop, a low is output on one row and then columns are checked. The loop continues until a low on a column is detected. The row of the pressed key is the row which is low at this moment and its column is the low column.

    At this stage we can determine the Scan code which is the 8-bit read from the input port. It consists of D0..D3 which represents the column of the pressed key and D4..D7 which is the row of the pressed key.

    ...more details, pls read http://www.aucegypt.edu/students/qua...h/keyboard.htm



  4. #4
    Full Member level 5
    Points: 3,731, Level: 14
    asic1984's Avatar
    Join Date
    Nov 2003
    Posts
    259
    Helped
    4 / 4
    Points
    3,731
    Level
    14

    keypad interfacing

    hi

    thanks for your help

    i want to make keypad scanning (software)...............but can u givemore details about how can i do it

    thanks for help



  5. #5
    Member level 2
    Points: 2,372, Level: 11

    Join Date
    May 2001
    Location
    Baenre compound, MENZOBERRANZAN
    Posts
    51
    Helped
    1 / 1
    Points
    2,372
    Level
    11

    key pad interfacing program for arm at91sam7s256

    write 3 routines:
    1) getRowValue
    - drive columns low sequentially
    - for each column driven low look for 2 rows (max) being low (this way you can implement chording)
    2) getKey
    - this calls routine 1 and returns max 2rows 2 columns = 2 keys pressed at the same time
    3) handleKeypad
    - this is your control algoritm

    You can also maintain an array of rows x columns and mask it against a previously scanned version of the array to get the changes in keys
    cheers



    •   Alt17th November 2004, 23:55

      advertising

        
       

  6. #6
    Advanced Member level 4
    Points: 11,937, Level: 26

    Join Date
    Jul 2001
    Posts
    1,060
    Helped
    92 / 92
    Points
    11,937
    Level
    26

    keypad interface what is

    Quote Originally Posted by asic1984
    hi

    thanks for your help

    i want to make keypad scanning (software)...............but can u givemore details about how can i do it

    thanks for help
    Which language are you using?

    If you are using C and the CCS compiler there are examples that come with the compiler. In this case take a look at them ...

    best regards



  7. #7
    Newbie level 4
    Points: 1,702, Level: 9
    Triple_X's Avatar
    Join Date
    Sep 2003
    Posts
    5
    Helped
    2 / 2
    Points
    1,702
    Level
    9

    keypad on parallel port

    this is my sample code, very easy to understand:

    ***************
    4x4 keypad
    +--+--+--+--+
    | 1 | 2 | 3 | A |
    +--+--+--+--+
    | 4 | 5 | 6 | B |
    +--+--+--+--+
    | 7 | 8 | 9 | C |
    +--+--+--+--+
    | * | 0 | # | D |
    +--+--+--+--+
    ****************
    // declare the variable first, i jump straight to the program
    while(!kbhit()) {
    for(i=0; i<4; i++) {
    p1 = 0xff & ~((1<<4) << i);
    // send p1 to IO where keypad is connected, for example GPIO
    setgpio(0x47, p1); // set row first, can use outportb() instead, send data to that index
    for(j=4; j<8; j++) { // scan keypress here
    c = getgpio(0x46); // read data from index, can use inportb()
    // results of keypress...
    switch(c) {
    // row 1
    case 0xee: printf("1 pressed."); delay(250); break; // put delay to avoid printing several times
    case 0xed: printf("2 pressed."); delay(250); break;
    case 0xeb: printf("3 pressed."); delay(250); break;
    case 0xe7: printf("A pressed."); delay(250); break;

    // row 2
    case 0xde: printf("4 pressed."); delay(250); break;
    case 0xdd: printf("5 pressed."); delay(250); break;
    case 0xdb: printf("6 pressed."); delay(250); break;
    case 0xd7: printf("B pressed."); delay(250); break;


    // row 3
    case 0xbe: printf("7 pressed."); delay(250); break;
    case 0xbd: printf("8 pressed."); delay(250); break;
    case 0xbb: printf("9 pressed."); delay(250); break;
    case 0xb7: printf("C pressed."); delay(250); break;

    // row 4
    case 0x7e: printf("* pressed."); delay(250); break;
    case 0x7d: printf("0 pressed."); delay(250); break;
    case 0x7b: printf("# pressed."); delay(250); break;
    case 0x77: printf("D pressed."); delay(250); break;

    default: break;
    }
    }
    }
    }

    ***note: setgpio() and getgpio() function was created to easily set and read data to/from index, of course you can create your own function with outportb() and inportb() - easy task! (is it??)

    I hope you can understand what is the code all about.

    best regards,
    Triple_X, MY
    Jom lawat Terengganu Kiteee :D


    2 members found this post helpful.

  8. #8
    Full Member level 5
    Points: 3,731, Level: 14
    asic1984's Avatar
    Join Date
    Nov 2003
    Posts
    259
    Helped
    4 / 4
    Points
    3,731
    Level
    14

    interfacing of keypad

    hi

    thanks all for help

    for nicleo: is this algorithm mean that i will connect the keypad directlly to parallel port without any interfacing to pullup resistors and positive supply voltage as what i already do (but characters are not reading correctly)

    also how can i overcome debounce problem

    if someone can send schematic for the connection

    and thanks all for help



    •   Alt22nd November 2004, 01:59

      advertising

        
       

  9. #9
    Advanced Member level 2
    Points: 21,612, Level: 35

    Join Date
    Sep 2004
    Posts
    662
    Helped
    72 / 72
    Points
    21,612
    Level
    35

    explain 3 x 4 array keypad matrix explain pdf

    Quote Originally Posted by asic1984
    for nicleo: is this algorithm mean that i will connect the keypad directlly to parallel port without any interfacing to pullup resistors and positive supply voltage as what i already do (but characters are not reading correctly)

    also how can i overcome debounce problem

    if someone can send schematic for the connection

    and thanks all for help
    For parallel port interfacing to keypad, I think you need pullup resistors as shown in Figure 1. You may also wish to read this INTERFACING WITH THE KEYPAD A MORE COMPLEX PARALLEL PORT EXAMPLE http://moi.unl.edu/classes/ee222F04/handouts/keypad.pdf

    Switch Debouncing (hardware)
    http://engnet.anu.edu.au/DEcourses/e...qdesnode9.html

    Switch Decouncing (software)
    http://www.hkln.net/doc/8051/example/debounce/index.htm



  10. #10
    Full Member level 5
    Points: 3,731, Level: 14
    asic1984's Avatar
    Join Date
    Nov 2003
    Posts
    259
    Helped
    4 / 4
    Points
    3,731
    Level
    14

    read a keypad by parallel port

    hi

    thanks every one for your help

    it works now



  11. #11
    Full Member level 2
    Points: 2,345, Level: 11

    Join Date
    Jun 2004
    Location
    India
    Posts
    128
    Helped
    2 / 2
    Points
    2,345
    Level
    11

    8052 interrupt keypad

    hi

    U can try with a keypad encoder also.
    Its not nessary to scan or poll. U can find the key when its pressed using the interrupt
    U can use the IC MM74C922 . even a layman can do the program using this

    Have a nice day

    Regards
    Gopi



  12. #12
    Junior Member level 2
    Points: 1,587, Level: 9

    Join Date
    May 2005
    Posts
    20
    Helped
    0 / 0
    Points
    1,587
    Level
    9

    4x4 matrix keypad scanning in c

    just want to say that this topic helped me a lot

    thanks for all



  13. #13
    Newbie level 3
    Points: 1,309, Level: 8

    Join Date
    Sep 2005
    Posts
    3
    Helped
    0 / 0
    Points
    1,309
    Level
    8

    noise generated by keypad

    HI
    I have problem with keypad interrupt. my 8051 colums comes from one port and rows from anther port and it havng one encoder interrupt from 74HCT21 how to scan this key pad using C rograming. pls help me out

    Regads
    wahid



  14. #14
    Member level 2
    Points: 1,639, Level: 9

    Join Date
    Aug 2005
    Posts
    53
    Helped
    1 / 1
    Points
    1,639
    Level
    9

    matrix keypad scanning in c

    learn
    8051 microcontrollers
    I SCOTT MACKENZIE or
    microcontrollers and interfacinmg
    by
    HALL



  15. #15
    Member level 5
    Points: 337, Level: 3

    Join Date
    Aug 2010
    Location
    Batangas - Malvar
    Posts
    84
    Helped
    2 / 2
    Points
    337
    Level
    3

    Re: keypad interfacing?

    hi
    how to use the 4x3 keypad?



  16. #16
    Super Moderator
    Points: 36,775, Level: 46
    Achievements:
    Created Album picturesCreated Blog entry7 years registered
    alexan_e's Avatar
    Join Date
    Mar 2008
    Location
    Greece
    Posts
    11,361
    Helped
    2037 / 2037
    Points
    36,775
    Level
    46
    Blog Entries
    6

    Re: keypad interfacing?

    Quote Originally Posted by akoangsimula View Post
    hi
    how to use the 4x3 keypad?
    You have asked the same question in 11 different threads in this forum in the last 2 hours,
    don't you think that 1 or 2 posts are enough?

    Alex



  17. #17
    Member level 5
    Points: 337, Level: 3

    Join Date
    Aug 2010
    Location
    Batangas - Malvar
    Posts
    84
    Helped
    2 / 2
    Points
    337
    Level
    3

    Re: keypad interfacing?

    Quote Originally Posted by alexan_e View Post
    You have asked the same question in 11 different threads in this forum in the last 2 hours,
    don't you think that 1 or 2 posts are enough?

    Alex
    i post in 11 threads but only sadly one person answer my question..



  18. #18
    Newbie level 4
    Points: 418, Level: 4

    Join Date
    Sep 2010
    Location
    Bangalore, India
    Posts
    5
    Helped
    0 / 0
    Points
    418
    Level
    4

    Re: keypad interfacing?

    you can use sx1508/sx1509 encoder to build your module and then interface it to controller



+ Post New Thread
Please login