51-高级闪烁流水灯

#include<reg52.h>                   //宏定义
#define uchar unsigned char   //宏定义
//定义5中闪烁方式 ,共阳极的led
uchar code table1[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
uchar code table2[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd};
uchar code table3[]={0x00,0xff,0x00,0xff,0x7e,0xbd,0xdb,0xe7,0xdb,0xbd,0x7e,0x00,0xff,0x00,0xff};
uchar code table4[]={0x7e,0x3c,0x18,0x00,0x18,0x3c,0x7e};
uchar code table5[]={0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00};
void delay(int b)//appellation:延时子函数;functions:延时一会
{
   int c,d;
for(c=b;c>=0;c--)
for(d=200;d>=0;d--);
}
void mian()//mian functions;主要起到调用子函数的功能

{
   int a;
   while(1)
{
   for(a=7;a>=0;a--)
   {
    P0=table1[a];
    delay(100);
   }
   for(a=6;a>=0;a--)
   {
    P0=table2[a];
    delay(100);
   }
   delay(200);
   for(a=0;a<=14;a++)
   {
    P0=table3[a];
    delay(200);
   } 
   for(a=0;a<=6;a++)
   {
    P0=table4[a];
    delay(200);
   }
   for(a=0;a<=7;a++)
   {
    P0=table5[a];
    delay(200);
   } 
}
}

你可能感兴趣的:(include,led,protues,阳极)