这个很容易嘛,你先设置一个寄存器,然后一直扫描两个按键(假设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
② c51单片机怎么用两个按键控制两个数码管的加减,加到99就好,求程序
1、首先先在proteus画出仿真图,方便仿真程序。
③ 单片机 用汇编语言怎么编写两个按键控制一个LED自加自减的程序
;共阳数码管
COUNTEQU30H
SP1EQUP3.6
SP2EQUP3.7
ORG0
AJMPMAIN
ORG30H
MAIN:MOVCOUNT,#0
MAIN1:MOVA,COUNT
MOVB,#10
DIVAB
MOVDPTR,#TAB
MOVCA,@A+DPTR
MOVP2,A
MOVA,B
MOVCA,@A+DPTR
MOVP1,A
K1:JBSP1,K2
JBSP1,$
LCALLDLY
JNBSP1,$
INCCOUNT
MOVA,COUNT
CJNEA,#100,MAIN1
LJMPMAIN
K2:JBSP2,K1
JBSP2,$
LCALLDLY
JNBSP2,$
MOVA,COUNT
CJNEA,#0,DEC1
MOVCOUNT,#100
DEC1:DECCOUNT
MOVA,COUNT
CJNEA,#100,MAIN1
LJMPMAIN
DLY:MOVR7,#20
D1:MOVR7,#248
DJNZR7,$
DJNZR6,$-4
RET
TAB:DB0C0H,0F9H,0A4H,0B0H,99H,092H,82H,0F8H,080H,090H