Keypad

Discussion in 'Programmer's Corner' started by Tuck3rz, Nov 12, 2009.

  1. Tuck3rz

    Thread Starter New Member

    Nov 4, 2009
    17
    0
    Hi, Does anyone knows how to configure a keypad which is connect in a microcontroller. 8051->8255-Keypad+LCD
    Port A and B are output ports and Port C is the input port for the keypad..

    But i have no clue how to start programming to display out the buttons that i press on the keypad to the LCD
     
  2. Tuck3rz

    Thread Starter New Member

    Nov 4, 2009
    17
    0
    is there anyone who can help me with this?
    I'm using keil C to program it by the way.. DS89450 chip is used.
     
  3. maxpower097

    Well-Known Member

    Feb 20, 2009
    795
    388
    Not familiar with your chip but the theory would be
    to read pins from Keypad to corisponding values. So if pins 1 and 3 were high = 1, if pins 1 and 4 were high = 2, etc.... So then store your values obtained in a variable then output them to the LCD. All pins and numbers are theoretical.
     
  4. BMorse

    Senior Member

    Sep 26, 2009
    2,675
    234

    On a 4x4 matrrix switch keypad, you will have 4 columns and 4 rows, one set has to be set as an output (column) and the other set have to be connected as inputs (rows)

    You then turn on each column and "scan" the rows to see witch one is "on", you will have to scan each row, and only one column should be on at a time to be able to "read" the key press from the rows....


    My .02
     
  5. maxpower097

    Well-Known Member

    Feb 20, 2009
    795
    388
    Ahhhh... makes sense.
     
  6. Tuck3rz

    Thread Starter New Member

    Nov 4, 2009
    17
    0
    Thank you all for the answers...
    For the rows and columm is read by the keypad itself?
    like Rows-1 , 2 , 3 ,A
    and columm is 1 , 4 , 7 , *?
     
  7. Tuck3rz

    Thread Starter New Member

    Nov 4, 2009
    17
    0
    Hey, i tried programming with the similar explainations, however the LCD screen shows a constant characters of "789C" even if i do not press any buttons. If buttons 1 2 3 or A is pressed the character in the columm will not be displayed.
    Example , if "1" is "89C" will be showed.
    To be exact, it is not acting as the way i want it to

    This is the link for my program.
    http://www.mediafire.com/?ikerogmmyww
     
  8. BMorse

    Senior Member

    Sep 26, 2009
    2,675
    234
    You have to tell set your own value when reading a keypress,


    Example:


    1. All columns are setup as outputs, all rows are set as inputs (Pulled Low to Vss with resistors).....
    2. start by turning all columns off,
    3. Turn on column 1,
    4. Check row 1 if there is an input, if input = High then Keypress =0x01, if input is Low, check next row....
    5. Check row 2, if High then Keypress = 0x04, if low check next row...
    6. check row 3, if high then keypress =0x07, if low check next row....
    7. check row 4, if high keypress = 0x0A, if low check next column...
    8. Set first column low, set next column high..... and repeat the above steps (4 through 7) but the keypress will equal the following for each column checked
    Column 1 is connected to key # 1,4,7,A
    Column 2 is connected to key # 4,5,6,E
    Column 3 is connected to key # 7,8,9,D
    column 4 is connected to key # A,0,B,C

    See attached pic for reference on the keys (buttons)

    [​IMG]

    See here for some sample code and a Pic tutorial on Hexadecimal Keypad Interfacing to a Pic >>> http://www.winpicprog.co.uk/pic_tutorial9.htm


    My .02
     
  9. Tuck3rz

    Thread Starter New Member

    Nov 4, 2009
    17
    0
    Hey thanks i found out already.. my program i configured the 8255 wrongly .

    Thanks alot bro..
     
  10. maxpower097

    Well-Known Member

    Feb 20, 2009
    795
    388
    I wanna throw a thanks out to Bmorse and Sarge. I've new and learning like all of us and it seems in this field on many of the other forums people have a bad attitude about helping us newbies. Anyways you guys basically are the nicest guys around and always go far out of your way to help us find what we need or explain what were looking at in a way we understand it. Just wanted to say thanks and wanted you guys to know I and I'm sure many more really really appreciate all your help.
     
Loading...