/***********************************************************
功能:花样流水灯
说明:适用于Breting研发的MINI板
时间:2012.12.19
作者:荆轩道
************************************************************/
#include<reg52.h>
#include<intrins.h>
#define uint unsigned int
#define uchar unsigned char
uchar shu;
void delay(uint t)//延时函数大约延时1ms
{
uint i,j;
for(i=0;i<t;i++)
for(j=0;j<120;j++);
}
void main()
{
uchar i=0,j=0;
while(1)
{
P0=0xfe; //用于首尾的逐渐灯闪烁
delay(300);
P0=0x7f;
delay(300);
P0=0xfd;
delay(300);
P0=0xbf;
delay(300);
P0=0xfb;
delay(300);
P0=0xdf;
delay(300);
P0=0xf7;
delay(300);
P0=0xef;
delay(300);
P0=0xfe; //点亮第一个灯
for(i=0; i<7; i++)
{
P0 = _crol_(P0, 1); //用于循环左移
delay(300);
}
P0 = 0x7f;
for(i=0; i<7; i++) //用于循环右移
{
P0 = _cror_(P0, 1); //_crol_()这个函数在intrins.h中定义了,用于循环右移
delay(300);
}
P0=0xfe; //点亮第一个灯
for(i=0; i<7; i++)
{
P0 = _crol_(P0, 1);
delay(300);
}
P0 = 0x7f;
for(i=0; i<7; i++)
{
P0 = _cror_(P0, 1);
delay(300);
}
P0=0x00; //全亮_逐渐灭掉
delay(300);
P0=0x01;
delay(300);
P0=0x03;
delay(300);
P0=0x07;
delay(300);
P0=0x0f;
delay(300);
P0=0x1f;
delay(300);
P0=0x2f;
delay(300);
P0=0x4f;
delay(300);
P0=0x7f;
delay(300);
P0=0xff;
delay(300);
P0=0xfe; //逐渐点亮
delay(300);
P0=0xfc;
delay(300);
P0=0xf8;
delay(300);
P0=0xf0;
delay(300);
P0=0xe0;
delay(300);
P0=0xc0;
delay(300);
P0=0x80;
delay(300);
P0=0x00;
delay(300);
P0=0x18; //从内到外逐渐灭掉
delay(300);
P0=0x3c;
delay(300);
P0=0x7e;
delay(300);
P0=0xff;
delay(300);
P0=0x7e; //从外到内逐渐点亮
delay(300);
P0=0x3c;
delay(300);
P0=0x18;
delay(300);
P0=0x00;
delay(300);
P0=0xff;
delay(300);
P0=0xe7; //从外到内逐渐点亮
delay(300);
P0=0xc3;
delay(300);
P0=0x81;
delay(300);
P0=0x00;
delay(300);
}
}