C51 程序练习
源代码在线查看: 3.c
//8个发光管来回流动,第个管亮100ms,流动时让蜂鸣器发出“滴滴”?
#include
#include
#define uint unsigned int
#define uchar unsigned char
sbit BEEP=P1^5;
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;
while(1)
{
temp=0xfe;
P2=temp;
for(i=0;i {
temp=_crol_(temp,1);
delay(1000);
P2=temp;
BEEP=0;
delay(250);
BEEP=1;
delay(250);
BEEP=0;
delay(250);
BEEP=1;
delay(250);
}
temp=0x7f;
P2=temp;
for(j=0;j {
temp=_cror_(temp,1);
delay(1000);
P2=temp;
BEEP=0;
delay(250);
BEEP=1;
delay(250);
BEEP=0;
delay(250);
BEEP=1;
delay(250);
}
}
}