51单片机C语言开发之花样流水灯程序

#include 

typedef unsigned char uchar;
typedef unsigned int uint; //int是16位的

sbit ADDR0 = P1^0;
sbit ADDR1 = P1^1;
sbit ADDR2 = P1^2;
sbit ADDR3 = P1^3;
sbit ENLED = P1^4;

void main(){
    uchar i;
    uint j;

    ENLED = 0;
    ADDR3 = 1;
    ADDR2 = 1;
    ADDR1 = 1;
    ADDR0 = 0;

    while(1){
        for(i=0; i<=7; i++){
            P0 = ~(0x01 << i);
            for(j=0; j<20000; j++) ;
        }
        for(i=6; i>=1; i--){
            P0 = ~(0x01 << i);
            for(j=0; j<20000; j++) ;
        }
    }
}

你可能感兴趣的:(51单片机C语言开发之花样流水灯程序)