[51]跑马灯

#include<reg52.h>
#include <intrins.h>
#define uint unsigned int 
#define uchar unsigned char 
void delay(uint z)
{
    uint x,y;
    for(x=z;x>0;x--)
        for(y=110;y>0;y--);    
}
void main()
{
    uchar temp=0xfe;
    while(1)
    {
    P1=temp;
    temp=_crol_(temp,1);
        if(temp==0xfe)
        {    
        temp=0x7f;
            while(1)
            {
             temp=_cror_(temp,1);
             delay(200);
             P1=temp;
             if(temp==0xfe){temp=0xfe;break;}
            }
        continue;
        }
    delay(200);
    }
}

猜你喜欢

转载自blog.csdn.net/echosun1996/article/details/51737027