9:43 AM
Interfacing of keyboard with 8051 Micro-controller with program code

Aim: Interfacing of keyboard with 8051 Microcontroller

Requirements: 8051, 11.0592MHz Crystal, 33pF (2), 10uF, 10K, push button

(5 piece for Key-Board),4k7 resistor,10k resistor, 1K (10), LCD, Bread Board, Connecting wires, 5V power supply

 

Circuit Diagram:

 

 

Program code:

 

//Interfacing of keyboard with lcd

org 0000h

acall lcd

acall keyboard

lcd:

mov a,#38h //2*16 matrix lcd

acall command

34 | P a g e

mov a,#0eh //dispaly on cursor on

acall command

mov a,#01h

acall command

mov a,#06h

acall command

mov a,#80h

acall command

ljmp code2

code2:

ret

command:

acall delay

mov p1,a

clr p3.0

clr p3.1

setb p3.2

acall delay

clr p3.2

ret

data1:

acall delay

mov p1,a

setb p3.0

clr p3.1

setb p3.2

acall delay

clr p3.2

acall delay

ret

delay:

mov r0,#15h

go:mov tmod,#01h

35 | P a g e

mov tl0,#0ffh

mov th0,#0dbh

setb tr0

back:jnb tf0,back

clr tr0

clr tf0

djnz r0,go

ret

keyboard:

mov p2,#0ffh

k1:mov p0,#00h //checking of keyboard's

mov a,p2

anl a,#03h

cjne a,#03h,k1

k2:

acall delay

mov a,p2

anl a,#03h

cjne a,#03h,over

sjmp k2

over:acall delay //checking for row

mov a,p2

anl a,#03h

cjne a,#03h,over1

sjmp k2

over1:

mov p0,#0feh

mov a,p2

anl a,#03h

cjne a,#03h,row0

mov p0,#0fdh

mov a,p2

anl a,#03h

36 | P a g e

cjne a,#03h,row1

ljmp k2

row0:

mov dptr,#code0

sjmp find

row1:

mov dptr,#code1

sjmp find

find:

rrc a

jnc match

inc dptr

sjmp find

match:

clr a

movc a,@a+dptr

acall data1

ljmp k1

code0:

db '1','2'

code1:

db '3','4'

end

 

Learning outcomes: to be written by the students in 50-70 words.

Views: 107 | Added by: vijoriya | Tags: 8051 Microcontroller, interfacing, Keyboard, Program code | Rating: 0.0/0
Total comments: 0
avatar