51單片機控制數碼管循環顯示0-9程序
采用***陰極LED數碼管,51單片機P1口輸出數據:ORG 0000H
JMP MAIN
ORG 0100H
MAIN:MOV DPTR,#TAB
MOV R1,#00H
DISP:MOV A,R1
MOVC A,@A+DPTR
MOV P1,A
LCALL DELAY
INC R1
CJNE R1,#0AH,DISP
SJMP $
TAB: DB 3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FHDELAY: MOV R4,#2
DELAY100MS:MOV R5,#200
DELAY5MS: MOV R6,#250
LOOP: DJNZ R6,LOOP
DJNZ R5,DELAY5MS
DJNZ R4,DELAY100MS
RET