C51源程序:
#include<reg51.h><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
void delay(void)
{
unsigned int i;
for(i=0;i<50000;i++);
return;
}
int main(void)
{
unsigned char led,led1,led2;
unsigned char i;
do
{
led=0x<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />7f;
for(i=1;i<=8;i++)
{
led1=led>>i;
led2=led<<(8-i);
P0=led1|led2;
delay();
}
}
while(1);
}
汇编源代码:
ORG 0000H
AJMP START
ORG 30H
START:MOV A,#7FH
MOV R0,#8
LOOP: RR A
MOV P0,A
ACALL DELAY
DJNZ R0,LOOP
AJMP START
DELAY:MOV R7,#20
DEL1: MOV R6,#100
DEL2: MOV R5,#248
DJNZ R5,$
DJNZ R6,DEL2
DJNZ R7,DEL1
RET
END
文章评论(0条评论)
登录后参与讨论