Vous êtes sur la page 1sur 4

lcd_port equ P1 ;LCD connected to Port1 in 4-bit mode

en equ P1.7 ;Enable connected to P1.7


rw equ P1.6
rs bit P1.5
te bit P2.4
delay equ 00H
temp equ 09H
com equ 0FCH
dat equ 0FDH
eot equ 0FEH
org 0000H
mov p2,#10H
mov 45H,#30H
mov 46H,#31H
mov 47H,#32H
mov 48H,#33H
mov sp,#0FH ;stack pointer=0FH
mov r3,#03H ;no of attempts to enter
wrong password after which access will be denied
mov dptr,#welcome
acall display
mov delay,#250 ;Delay 250mS
acall delayms
mov dptr,#askpass
acall display
sjmp key
send:
mov p2,#01H ;encoder interfaced to p
ort 2
loop:
sjmp loop

KEY:
mov r1,#40H
mov dptr,#lcd_init
acall display
nexkey:
MOV DELAY,#1
ACALL DELAYMS
MOV P3,#0FEH
MOV A,P3
ANL A,#0F0H
CJNE A,#0F0H,ROW_0
MOV P3,#0FDH
MOV A,P3
ANL A,#0F0H
CJNE A,#0F0H,ROW_1
MOV P3,#0FBH
MOV A,P3
ANL A,#0F0H
CJNE A,#0F0H,ROW_2
MOV P3,#0F7H
MOV A,P3
ANL A,#0F0H
CJNE A,#0F0H,ROW_3
SJMP nexkey
ROW_0:
MOV DPL,#"0"
RO1: RLC A
JNC MATCH
INC DPL
SJMP RO1
ROW_1:
MOV DPL,#"4"
RO2: RLC A
JNC MATCH
INC DPL
SJMP RO2
ROW_2:
MOV DPL,#"8"
RO3: RLC A
jnc match
inc dpl
sjmp RO3

ROW_3:
MOV DPL,#"C"
RO4: RLC A
JNC MATCH
INC DPL
SJMP RO4
MATCH: mov @r1,dpl
inc r1
mov dptr,#star
acall display
cjne r1,#44H,jnexkey
ljmp codecheck
jnexkey:
ljmp nexkey

codecheck:
mov r1,#40H
SC equ 45H
nexcode:
mov a,@r1
cjne a,SC,wrong
inc r1
inc sc
cjne r1,#44H,nexcode
mov dptr,#proceed
acall display
mov p2,#0FFH
ljmp loop
wrong:
djnz r3,nexatt
sjmp acdens
nexatt:
mov dptr,#wpass
acall display
mov dptr,#askpasa
acall display
ljmp key
acdens:
mov dptr,#accden
acall display
mov p2,#00H
ljmp loop
display:
clr a
movc a,@a+dptr
inc dptr
cjne a,#eot,comd
ret
comd:
cjne a,#com,datta
mov 50H,#00H
sjmp display
datta:
cjne a,#dat,sendit
mov 50H,#20H
sjmp display
sendit: ;LCD data Routine
mov temp,a ;Keep copy of data in temp
swap a ;We need higher nibble
anl a,#0FH ;Mask first four bits
add a,#80H ;Enable = 1
orl a,50H
mov lcd_port,a ;Move to lcd port
nop
clr en ;Enable = 0
mov a,temp ;Reload the data from temp
anl a,#0FH ;we need lower nibble now
add a,#80H ;Enable = 1
orl a,50H
mov lcd_port,a ;Move to lcd port
nop
clr en ;Enable = 0
mov delay,#255 ;Delay 1mS
acall delayms
sjmp display
delayms:
mov r4,#delay
again:
mov r5,#250
here:
nop
nop
djnz r5,here
djnz r4,again
ret
welcome:
db com,2CH,0CH,06H,01H,83H,dat,"Welcome to",com,0C2H,dat,"Auto P
arking",eot
askpass:
db com,2CH,0CH,06H,01H,81H,dat,"Enter Password",eot
lcd_init:
db com,2CH,0EH,06H,01H,80H,eot
star:
db dat,"*",eot
wpass:
db com,2CH,0CH,06H,01H,81H,dat,"Wrong Password",eot
askpasa:
db com,2CH,0CH,06H,01H,82H,dat,"Enter correct",com,0C4h,dat,"pas
sword",eot
proceed:
db com,2CH,0CH,06H,01H,80H,dat,"Proceed to slot",com,0C2H,dat,"N
o displayed",eot
accden:
db com,2CH,0CH,06H,01H,81H,dat,"Access denied",eot
end

Vous aimerez peut-être aussi