发布网友 发布时间:2022-04-23 21:38
共1个回答
热心网友 时间:2023-09-17 22:34
这个很容易嘛,你先设置一个寄存器,然后一直扫描两个按键(假设K1按下为加,K2按下为减),假设检测到K1被按下,寄存器就加1,如果检测到K2被按下,寄存器就减1;然后再调用显示函数就OK了。、 ORG 0000H
LJMP START
ORG 0030H
START:
MOV R2, #1
LOOP:
CALL DISP
JB P1.6, NEXT
CALL DL10MS
JB P1.6, NEXT
JNB P1.6, $
DJNZ R2, NEXT
MOV R2, #10
NEXT:
JB P1.7, LOOP
CALL DL10MS
JB P1.7, LOOP
JNB P1.7, $
INC R2
CJNE R2, #11, LOOP
JMP START
;----------------------------------------
DISP:
MOV A, R2
DEC A
MOV DPTR, #TAB
MOVC A, @A + DPTR
MOV P2, A
RET
DL10MS:
MOV R6, #20
DJNZ R7, $
DJNZ R6, $ - 2
RET
;----------------------------------------
TAB:
DB 0C0H, 0F9H, 0A4H, 0B0H, 99H
DB 92H, 82H, 0F8H, 80H, 90H
;----------------------------------------
END