主题:60岁的我学编程--流水灯变多个花样
#include<reg52.h>
#include<intrins.h>
#define uint unsigned int
#define uchar unsigned char
void delay(uint );
uint a;
void main()
{
a=0x7f;
while(1)
{
delay(10);
P1=a;
a=_crol_(a,9); /*改变括号内的数就能改变流动方方向*/
/*a 设为7方向向右,其它向左*/
}
}
void delay(uint z )
{
uint x,y;
for(x=z;x>0;x--)
for(y=100;y>0;y--);
}
这是学编程序第八天的收获,可将流水灯变为间隔二,三,四,流动,可让一只常亮,也可让一只闪亮,可向左向右流动,等,都只需改变a 的值就可以,其它不变
#include<intrins.h>
#define uint unsigned int
#define uchar unsigned char
void delay(uint );
uint a;
void main()
{
a=0x7f;
while(1)
{
delay(10);
P1=a;
a=_crol_(a,9); /*改变括号内的数就能改变流动方方向*/
/*a 设为7方向向右,其它向左*/
}
}
void delay(uint z )
{
uint x,y;
for(x=z;x>0;x--)
for(y=100;y>0;y--);
}
这是学编程序第八天的收获,可将流水灯变为间隔二,三,四,流动,可让一只常亮,也可让一只闪亮,可向左向右流动,等,都只需改变a 的值就可以,其它不变