这样左移的延迟大高李一点的!
C语言
#include<reg51.h>
void delay(unsigned int a)
{
unsigned i,j
for(i=0i<ai++)
for(j=0j<1000j++)
}
main()
{
unsigned LED,i
LED = 0xfe
EA = 0
while(1)
{
for(i=0i<7i++){delay(100)LED = (LED<<1)|0x01P3 = 正滑纳LED}
for(i=0i<7i++){delay(100)LED = (LED>让槐>1)|0x80P3 = LED}
}
}
汇编语言
LED EQU 30H
ORG 0000H
LJMP MAIN
ORG 0030H
MAIN:
CLR EA
MOV SP,#5FH
MOV LED,#0FEH
MOV R0,#7
LOOP:
MOV R7,#50
LCALL DELAY
MOV A,LED
RL A
MOV LED,A
MOV P3,A
DJNZ R0,LOOP
MOV R0,#7
LOOP1:
MOV R7,#50
LCALL DELAY
MOV 举没A,LED
RR A
MOV LED,A
MOV P3,A
DJNZ R0,LOOP1
MOV R0,#7
SJMP LOOP
----------------------------
DELAY:
MOV R2,#8
DLY1:
MOV R3,#250
DJNZ R3,$
DJNZ R2,DLY1
DJNZ R7,DELAY
RET
-----------------------------
END
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)