單片機(jī)一鍵多功能按鍵識(shí)別設(shè)計(jì)
5.程序框圖
圖4.9.2
6.匯編源程序
ID EQU 30H
SP1 BIT P3.7
L1 BIT P1.0
L2 BIT P1.1
L3 BIT P1.2
L4 BIT P1.3
ORG 0
MOV ID,#00H
START: JB K1,REL
LCALL DELAY10MS
JB K1,REL
INC ID
MOV A,ID
CJNE A,#04,REL
MOV ID,#00H
REL: JNB K1,$
MOV A,ID
CJNE A,#00H,IS0
CPL L1
LCALL DELAY
SJMP START
IS0: CJNE A,#01H,IS1
CPL L2
LCALL DELAY
SJMP START
IS1: CJNE A,#02H,IS2
CPL L3
LCALL DELAY
SJMP START
IS2: CJNE A,#03H,IS3
CPL L4
LCALL DELAY
SJMP START
IS3: LJMP START
DELAY10MS: MOV R6,#20
LOOP1: MOV R7,#248
DJNZ R7,$
DJNZ R6,LOOP1
RET
DELAY: MOV R5,#20
LOOP2: LCALL DELAY10MS
DJNZ R5,LOOP2
RET
END
評(píng)論