(1)D1~D8八个彩灯按规定顺序依次点亮(间隔1秒),最后全亮;
(2)按规定顺序依次熄灭(间隔1秒),最后全灭;
(3)八个灯同时点亮,保持1秒;
(4)八个灯同时熄灭,保持0.5秒;
再将第3、4步重复4遍,最后整个程序再重复N遍
程序如下:
ORG 0000H
LJMP MAIN
ORG 0100H
MAIN: MOV R7,#7
LOOP: MOV R6,#16
MOV R5,#4
MOV DPTR,#TABLE
MOV R4,#0
LOOP1: MOV A,R4
MOVC A,@A+DPTR
MOV P1,A
INC R4
LCALL DELAY
LCALL DELAY
DJNZ R6,LOOP1
LOOP2: MOV P1,#0FFH
LCALL DELAY
LCALL DELAY
MOV P1,#00H
LCALL DELAY
DJNZ R5,LOOP2
DJNZ R7,LOOP
DELAY: MOV R1,#4
A1: MOV R2,#0FFH
A2: MOV R3,#0FFH
DJNZ R3,$
DJNZ R2,A2
DJNZ R1,A1
RET
TABLE:
DB 0FEH,0FCH,0F8H,0F0H,0E0H,0C0H,080H,000H ;逐个叠加
DB 080H,0C0H,0E0H,0F0H,0F8H,0FCH,0FEH,0FFH ;逐个递减
SJMP $
END