KEY EQU P3.2
LED EQU P1
ORG 0000H
LJMP MAIN
ORG 0030H
MAIN:
CLR 00H
MOV A,#0FEH
LOOP:
JB P3.2,LOOP1
JNB P3.2,$
CPL 00H
LOOP1:
JB 00H,LOOP2
MOV LED,#0FFH
SJMP LOOP
LOOP2:
MOV P1,A
RL A
LCALL DELAY
SJMP LOOP
DELAY:
MOV R2,#200
DLY1:
MOV R3,#250
DJNZ R3,$
DJNZ R2,DLY1
RET
END
KEY BIT P1.0LED EQU 30H
ORG 0000H
LJMP MAIN
ORG 0030H
MAIN:
MOV LED,#0FEH
MOV R2,#8
LOOP:
MOV P0,LED
MOV A,LED
RL A
MOV LED,A
JNB KEY,KEYC
DJNZ R2,LOOP
MOV R2,#8
LOOP1:
MOV P0,LED
MOV A,LED
RR A
MOV LED,A
JNB KEY,KEYC
DJNZ R2,LOOP1
SJMP LOOP
KEYC:
MOV P0,#00H
JNB KEY,KEYC
LJMP LOOP
END
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)