单片机:跑马灯程序源代码 易理解,第2:从上到下 第3:从下到上,第1有些代码没起作用

#include<reg51.h>
#include <intrins.h>
char LED;
void delay(unsigned int i)
{
    unsigned char j;
    for(i; i > 0; i--)
        for(j = 255; j > 0; j--);

}
 main()
{
    unsigned char LED;
    unsigned int i;
    LED = 0xfe;
    P1 = LED;
    while(1)
    {
        delay(250);
        if (LED==0Xfe)
            {
                for (i=1;i<=7;i++)
                    {
                        LED = _crol_(LED,1);
                        delay(250);        
                        P1 = LED;
                    }    
            }
    if (LED==0X7F)
    {
        for (i=1;i<=7;i++)
            {
                LED=_cror_(LED,1);
                delay(250);
                P1 = LED;
            }
    }
    }
}

 

#include<reg51.h>
#include <intrins.h>
char LED;
void delay(unsigned int i)
{
    unsigned char j;
    for(i; i > 0; i--)
        for(j = 255; j > 0; j--);

}
 main()
{
    unsigned char LED;
    unsigned int i,j;
    LED = 0x7f;
    P1 = LED;
    while(1)
    {
        for (i=1;i<=7;i++)
                    {
                        LED = _cror_(LED,1);
                        delay(250);        
                        P1 = LED;
                    }    
            
    
        for (j=1;j<=7;j++)
            {
                LED=_crol_(LED,1);
                delay(250);
                P1 = LED;
            }
    
    }
}
#include<reg51.h>
#include <intrins.h>
char LED;
void delay(unsigned int i)
{
    unsigned char j;
    for(i; i > 0; i--)
        for(j = 255; j > 0; j--);

}
 main()
{
    unsigned char LED;
    unsigned int i,j;
    LED = 0xfe;
    P1 = LED;
    while(1)
    {
        for (i=1;i<=7;i++)
                    {
                        LED = _crol_(LED,1);
                        delay(250);        
                        P1 = LED;
                    }    
            
    
        for (j=1;j<=7;j++)
            {
                LED=_cror_(LED,1);
                delay(250);
                P1 = LED;
            }
    
    }
}

 

posted @ 2021-08-08 17:35  myrj  阅读(728)  评论(0编辑  收藏  举报