quet led don
chao cac ban ! day la chuong trinh quet led tu trai qua phai ,ai co the giup dum minh chay tu phai qua trai duoc khong vay .nhanh he ! cam on he
$MOD51
ORG 00H
MAIN:
ACALL CHOPTAT
ACALL DEMLEN
ACALL SANGDUOI
ACALL SANGDAN
ACALL SANGDON
SJMP MAIN
CHOPTAT:
MOV R7,#5
SOLAN1:
MOV P0,#00H
LCALL DELAY500MS
MOV P0,#0FFH
LCALL DELAY500MS
DJNZ R7,SOLAN1
RET
DEMLEN:
MOV R7,#2
SOLAN2:
MOV P0,#00H
LCALL DELAY500MS
LAP1:
INC P0
LCALL DELAY500MS
MOV A,P0
CJNE A,#00H,LAP1
DJNZ R7,SOLAN2
RET
SANGDUOI:
MOV R7,#5
SOLAN3:
MOV A,#01H
CLR C
LAP2:
MOV P0,A
LCALL DELAY500MS
RLC A
JNC LAP2
DJNZ R7,SOLAN3
RET
SANGDAN:
MOV R7,#5
SOLAN4:
MOV A,#00H
LAP3:
SETB C
MOV P0,A
LCALL DELAY500MS
RLC A
JNC LAP3
DJNZ R7,SOLAN4
RET
SANGDON:
MOV R7,#3
SOLAN5:
MOV R0,#08H
MOV R1,#00H
LAP4:
MOV R2,#00H
MOV R3,#01H
LAP5:
MOV A,R3
ORL A,R1
MOV P0,A
LCALL DELAY500MS
MOV A,R3
RL A
MOV R3,A
DJNZ R2,LAP5
DEC R0
SETB C
MOV A,R1
RRC A
MOV R1,A
CJNE R0,#00H,LAP4
MOV P0,#00H
ACALL DELAY500MS
DJNZ R7,SOLAN5
RET
DELAY500MS:
PUSH 00H
MOV R0,#100
MOV TMOD,#01H
LOOP2:
MOV TH0,#0F6H
MOV TL0,#3CH
SETB TR0
JNB TF0,$
CLR TR0
CLR TF0
DJNZ R0,LOOP2
POP 00H
RET
END
chao cac ban ! day la chuong trinh quet led tu trai qua phai ,ai co the giup dum minh chay tu phai qua trai duoc khong vay .nhanh he ! cam on he
$MOD51
ORG 00H
MAIN:
ACALL CHOPTAT
ACALL DEMLEN
ACALL SANGDUOI
ACALL SANGDAN
ACALL SANGDON
SJMP MAIN
CHOPTAT:
MOV R7,#5
SOLAN1:
MOV P0,#00H
LCALL DELAY500MS
MOV P0,#0FFH
LCALL DELAY500MS
DJNZ R7,SOLAN1
RET
DEMLEN:
MOV R7,#2
SOLAN2:
MOV P0,#00H
LCALL DELAY500MS
LAP1:
INC P0
LCALL DELAY500MS
MOV A,P0
CJNE A,#00H,LAP1
DJNZ R7,SOLAN2
RET
SANGDUOI:
MOV R7,#5
SOLAN3:
MOV A,#01H
CLR C
LAP2:
MOV P0,A
LCALL DELAY500MS
RLC A
JNC LAP2
DJNZ R7,SOLAN3
RET
SANGDAN:
MOV R7,#5
SOLAN4:
MOV A,#00H
LAP3:
SETB C
MOV P0,A
LCALL DELAY500MS
RLC A
JNC LAP3
DJNZ R7,SOLAN4
RET
SANGDON:
MOV R7,#3
SOLAN5:
MOV R0,#08H
MOV R1,#00H
LAP4:
MOV R2,#00H
MOV R3,#01H
LAP5:
MOV A,R3
ORL A,R1
MOV P0,A
LCALL DELAY500MS
MOV A,R3
RL A
MOV R3,A
DJNZ R2,LAP5
DEC R0
SETB C
MOV A,R1
RRC A
MOV R1,A
CJNE R0,#00H,LAP4
MOV P0,#00H
ACALL DELAY500MS
DJNZ R7,SOLAN5
RET
DELAY500MS:
PUSH 00H
MOV R0,#100
MOV TMOD,#01H
LOOP2:
MOV TH0,#0F6H
MOV TL0,#3CH
SETB TR0
JNB TF0,$
CLR TR0
CLR TF0
DJNZ R0,LOOP2
POP 00H
RET
END
Comment