|||
//8个发光管间隔200ms由上而下,再由下而上,
//再重复一次,然后全部熄灭再以300ms间隔全部闪烁5次,
//重复此过程
#include <intrins.h>
#include <reg52.h>
#define uint unsigned int
#define uchar unsigned char
void delay(uint);
void light1();
void light2();
void light3();
uchar temp;
int a1,a2,a3;
void main()
{
while(1)
{
light1();
light2();
light3();
}
}
void light1()
{
temp=0xfe;
P1=temp;
a1=8;
while(a1)
{
delay(30);
temp=_crol_(temp,1);
P1=temp;
a1--;
}
}
void light2()
{
temp=0x7f;
P1=temp;
a2=8;
while(a2)
{
delay(30);
temp=_cror_(temp,1);
P1=temp;
a2--;
}
}
void light3()
{
a3=5;
while(a3)
{
P1=0x0;
delay(45);
P1=0xff;
delay(45);
a3--;
}
}
void delay(uint z)
{
uint x, y;
beep=1;
for(x=z;x>0;x--)
for(y=765;y>0;y--) {}
}
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-11-23 10:47
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社