单片机p1端口接8个LED灯,D0点亮后闪烁一次 ,D1点亮后闪烁两次,D2点亮后闪烁三次以此类推

2024-12-03 04:53:10
推荐回答(1个)
回答1:

LED EQU 30H
ORG 0000H
LJMP MAIN
ORG 0030H
MAIN:
MOV LED,#0FEH
MOV R2,#1
LOOP:
MOV A,LED
MOV P1,A
LCALL DELAY
PUSH 02H
SHAN:
MOV P1,#0FFH
LCALL DELAY
MOV P1,A
LCALL DELAY
DJNZ R2,SHAN
POP 02H
INC R2
CLR C
RLC A
MOV LED,A
JNZ LOOP
SJMP $
DELAY:
MOV R3,#250
DLY:
MOV R4,#250
DJNZ R4,$
DJNZ R3,DLY
RET
END