C51 程序练习
源代码在线查看: 5.c
//8个发光管间隔200ms由上至下,再由下至上,再重复一次,
//然后全部熄灭再以300ms间隔全部闪烁5次。重复此过程
#include
#include
#define uint unsigned int
#define uchar unsigned char
uchar temp;
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void main()
{
uchar i,j,a,b;
while(1)
{
for(a=0;a {
temp=0xfe;
P2=temp;
for(i=0;i {
temp=_crol_(temp,1);
delay(100);
P2=temp;
}
temp=0x7f;
P2=temp;
for(j=0;j {
temp=_cror_(temp,1);
delay(100);
P2=temp;
}
}
temp=0xff;
P2=temp;
delay(300);
for(b=0;b {
temp=0x0;
P2=temp;
delay(300);
temp=0xff;
P2=temp;
delay(300);
}
}
}