每隔一秒闪烁的流水灯

#include


void main()
{


   unsigned char tmp = 0;
   unsigned char mnt = 0;
   unsigned char fag = 0;
 


   TMOD = 0x01;
   TH0 = 0xb8;
   TL0 = 0x00;
   TR0 = 1;


   while(1)
   {
   if(TF0 == 1)
{
TF0 = 0;  
            TH0 = 0xb8;
            TL0 = 0x00;
mnt++;


}
if(mnt == 50)
{
P0=~(0x01 << tmp);
tmp++;
mnt = 0;

if(tmp == 8)
{
   mnt = 51;
}
 


}
if(mnt == 101)
{
P0 = ~(0x40 >> fag);
fag++;
mnt = 51;
if(fag == 6)
{  
   mnt = 0;

tmp = 0;
fag = 0;
}



}


   
   }



}

你可能感兴趣的:(每隔一秒闪烁的流水灯)