51单片机点亮双向流水灯

#include 
#include 
#define uint unsigned int 
#define uchar unsigned char
sfr P0M0 = 0x94;
sfr P0M1 = 0x93;
void delay(uint ms){
    uint i,j;
    for(i = 0 ;i < ms ; i++)
        for (j = 0;j < 121;j++);
}
void display(){
    uint i,j;
    for(i = 0;i < 7;i++){
         P0 = _crol_(P0,1);
        delay(500);
    }
    for(j = 0;j < 7;j++){
        P0 = _cror_(P0,1);
        delay(500);
    }

}
void main(){
    P0M0 = 0x00;
    P0M1 = 0x00;
    P0 = 0xfe;
    while(1){
        display();
    }
}

 

转载于:https://www.cnblogs.com/weimin1314/p/8260534.html

你可能感兴趣的:(嵌入式,c/c++)