#include#define uchar unsigned char#define uint unsigned intvoid delay(uint t)//延時(shí)函數(shù){uint x,y;for(x=t;x>0;x--)for(y=110;y>0;y--);}void main()//主函數(shù){uchar temp,i;while(1){temp=0x01; //8盞燈單個(gè)亮向左移for(i=0;i<8;i++){P2=~temp;delay(50);temp<<=1;}temp=0x80;for(i=0;i<8;i++)//8盞燈單個(gè)亮反向右移{P2=~temp;delay(50);temp>>=1;}temp=0xfe; for(i=0;i<8;i++)//8盞燈逐個(gè)向右亮{P2=temp;delay(50);temp<<=1;}temp=0xfe; for(i=0;i<8;i++)//8盞燈逐個(gè)滅向右{P2=~temp;delay(50);temp<<=1;}temp=0x7f; for(i=0;i<8;i++)//8盞燈逐個(gè)亮向左{P2=temp;delay(50);temp>>=1;}temp=0x7f; for(i=0;i<8;i++)//8盞燈逐個(gè)滅向右{P2=~temp;delay(50);temp>>=1;}delay(100);P2=0x55;//隔一個(gè)亮delay(100);P2=0xaa;//隔一個(gè)亮delay(100);P2=0x00;//全亮delay(100);P2=0xff;//全滅}}
評(píng)論