;---------------------------------------------------------
K1 BIT P1.4
K2 BIT P1.5
K3 BIT P1.6
K4 BIT P1.7
FLAG0 BIT 20H.0 ;LED0标记
FLAG1 BIT 20H.1 ;LED1标记
FLAG2 BIT 20H.2 ;LDE2标记
FLAG3 BIT 20H.3 ;LED3标记
K_OLD EQU 30H
K_NEW EQU 31H
;---------------------------------------------------------
ORG 0000H
JMP MAIN
ORG 0030H
;---------------------------------------------------------
MAIN:
MOV SP,#60H
MOV P1,#0FFH
MOV P0,#0FFH
MOV K_OLD,#00H
MOV 20H,#0FFH
MAIN1:
CALL K_SCAN ;键扫描
MOV A,K_NEW
CJNE A,K_OLD,MAIN2
JMP MAIN1
MAIN2:
CALL DELAY ;延时示去抖动
CALL K_SCAN ;再判断键是否按下
MOV A,K_NEW
CJNE A,K_OLD,MAIN3
JMP MAIN1
文章评论(0条评论)
登录后参与讨论