단편기【1】: LED 유수등

3870 단어 단편기
LED 유수등【단방향】
#include <reg52.h>

sbit LED1 = P1^1;

sbit LED7 = P1^7;



void delay(unsigned int s);

// code:    ROM,    ROM

//      RAM,    RAM。

/*

unsigned char code table[] = {

    0xfe, 0xfd, 0xfb, 0xf7,

    0xef, 0xdf, 0xbf, 0x7f

};

*/



main()

{

    unsigned char i=0; // 0~65535

    unsigned char j;

    LED7 = 0; //   P1.7



    P1 = 0xFE;

    while(1) {

        /*

         * While    2        

         *      2 ,  2     

         */

        //LED1 = 0; // P1.1  

        //delay(1);

                                                 

        //LED1 = 1; // P1.1  

        //delay(1);



        //   

        /*

        for(i=0;i<8;i++) {

            P1 = table[i];

            delay(1);

        }

        */



        //   

        j = P1;

        j = j << 1;

        if(j != 0xFE) j = j | 0x01;

        P1 = j;

        delay(1);

    }

    return 0;

}



void delay(unsigned int s)

{

    unsigned int i, end;



    end = s*30000;

    for(i=0;i<end;i++);

}

좋은 웹페이지 즐겨찾기