JeritanBlog telah ditukar nama BelajarBlogs...
Home » » Interface 4x4 matrix keypad using 74C922 decoder to 8051 microcontroller

Interface 4x4 matrix keypad using 74C922 decoder to 8051 microcontroller



Interface 4x4 matrix keypad using 74C922 decoder to 8051 microcontroller . I have build hardware circuit on Breadboard. There are many way to program the keypad and i have learned many things from my lecturer and i just want to share what i have learn from my class. Below is a video that I've been done  this activity.

Interface 4x4 matrix keypad using 74C922 decoder to 8051 microcontroller . http://www.belajarblogs.com/2015/09/interface-4x4-matrix-keypad-using.html
Posted by Belajar Blogs on Tuesday, 8 September 2015
  • Keyboards are organized in a matrix of row and columns.

         # The CPU accesses both rows and columns through ports.
              + Therefore,with two 8-bit ports, and 8 x 8 matrix of keys can be connected to a                                        microprocessor

         # When a key pressed, a row and a column make a contact.
               + Otherwise,There is no connection between rows and columns

  • In IBM PC keyboards, a single microcontroller takes care of hardware and software interfacing.
  • A 4x4 matrix connected to two ports.
             # The rows are connected to an output port and the columns are connected to an input port




LCD display wiring part:

Click for see large image


Assembly program and insert code as follows into the Keil Uvision  :

Click for see large image

e        equ p2.7    ;lcd wiring
rw        equ    p2.6
rs        equ    p2.5
lcdline    equ    p3

keypad    equ p1       ;        keypad wiring
key_da    equ    p1.4

        org 00h
start:    acall    lcdst        ;start lcd
        mov dptr,#word1     ;display word
        acall    wdisp
loop:    mov a,#0c2h  
        acall    cmdwrt
        acall    getkey
        cjne a,#'+',next
        mov dptr,#word2
        acall    wdisp
        sjmp loop
next:    cjne a,#'C',next2
        mov    a,#01h
        acall    cmdwrt
        sjmp loop
next2:    acall    datawrt
        sjmp loop

getkey:    jnb    key_da,getkey ;get keypad key
        mov    a,keypad
        anl a,#0fh
        mov    dptr,#keymap
        movc a,@a+dptr
wait:    jb    key_da,wait
        ret

lcdwrt:    clr        rw           ;write to lcd
        mov    lcdline,a
        setb e
        acall    lcddly
        clr e
        acall    lcddly
        ret

cmdwrt:    clr    rs            ;write command to lcd
        acall    lcdwrt
        ret

datawrt:setb    rs            ;write data to lcd
        acall    lcdwrt
        ret

lcdst:    mov a,#38h            ;start lcd
        acall    cmdwrt
        mov a,#0ch
        acall    cmdwrt
        mov a,#01h
        acall    cmdwrt
        mov a,#06h
        acall    cmdwrt
        ret

wdisp:    clr a             ;display word
        movc a,@a+dptr
        jz    done
        acall    datawrt
        inc    dptr
        sjmp wdisp
done:    ret

lcddly:    mov r7,#200        ;delay for lcd
wa:    djnz r7,wa
        ret



word1:    db    "keypad test",0
word2:    db    "8051",0
keymap:db    '7','8','9','/'  
        db    '4','5','6','*'
        db    '1','2','3','-'
        db    'O','0','=','+'
        end

0 comments:

Blogger Tricks And TipsComment here