#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
void Delayms(uint x)
{
uint i,j;
for(i=x;i>0;i--)
for(j=110;j>0;j--);
}
void main(){
uchar i,j;
while(1)
{
j=0x01; //8个流水灯逐个闪动
for(i=0;i<8;i++)
{
P0=~j;
Delayms(300);
j<<=1;
}
j=0x80; //8个流水灯反向逐个闪动
for(i=0;i<8;i++)
{
P0=~j;
Delayms(300);
j>>=1;
}
}
}
温馨提示:内容为网友见解,仅供参考