在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<menu id="6qfwx"><li id="6qfwx"></li></menu>
    1. <menu id="6qfwx"><dl id="6qfwx"></dl></menu>

      <label id="6qfwx"><ol id="6qfwx"></ol></label><menu id="6qfwx"></menu><object id="6qfwx"><strike id="6qfwx"><noscript id="6qfwx"></noscript></strike></object>
        1. <center id="6qfwx"><dl id="6qfwx"></dl></center>

            新聞中心

            EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 單片機定時器0實現(xiàn)信號交通燈程序

            單片機定時器0實現(xiàn)信號交通燈程序

            作者: 時間:2016-12-02 來源:網(wǎng)絡(luò) 收藏
            本程序所用的原理圖下載:點這里,單片機芯片使用的stc89c52

            /*
            *功能:定時器0實現(xiàn)信號交通燈
            *
            *日期:2013-05-07-08:41
            *作者:徐冉
            *特別說明:本程序代碼已經(jīng)通過調(diào)試,僅供學(xué)習(xí)使用;
            *
            */
            /***********AT89C52-RC單片機實驗板***********/
            /*****************51hei-開發(fā)板*********************/
            #include
            typedef unsigned int uint;
            typedef unsigned char uchar;
            sbit LED_hong = P1^0;//紅信號燈
            sbit LED_lv = P1^2; //綠信號燈
            sbit wela = P2^7;
            sbit dula = P2^6;
            uchar code table[] = {
            0x3F, //"0"
            0x06, //"1"
            0x5B, //"2"
            0x4F, //"3"
            0x66, //"4"
            0x6D, //"5"
            0x7D, //"6"
            0x07, //"7"
            0x7F, //"8"
            0x6F, //"9"
            0x77, //"A"
            0x7C, //"B"
            0x39, //"C"
            0x5E, //"D"
            0x79, //"E"
            0x71, //"F"
            0x76, //"H"
            0x38, //"L"
            0x37, //"n"
            0x3E, //"u"
            0x73, //"P"
            0x5C, //"o"
            0x40, //"-"
            0x00, //熄滅
            0x00 //自定義
            };
            uchar num = 30, counter;
            void init();
            void display(uint num);
            void delay(uint xms);
            void main()
            {
            init();
            while(1)
            {
            if(counter == 50)
            {
            counter = 0;
            num--;
            if(num == 0)
            {
            num = 30;
            LED_hong = ~LED_hong;
            LED_lv = ~LED_lv;
            }
            }
            display(num);
            }
            }

            本文引用地址:http://www.biyoush.com/article/201612/324637.htm


            void init()
            {
            LED_hong = 0;
            LED_lv = 1;
            TMOD = 0x01;
            TH0 = 0xB8;
            TL0 = 0x00;
            TR0 = 1;
            EA = 1;
            ET0 = 1;


            }


            void display(uint num)
            {
            uchar shi, ge;


            shi = num / 10 % 10;
            ge = num % 10;


            dula = 1;
            P0 = table[shi];
            dula = 0;
            P0 = 0xff;
            wela = 1;
            P0 = 0xfe;
            wela = 0;
            P0 = 0x00;
            delay(1);


            dula = 1;
            P0 = table[ge];
            dula = 0;
            P0 = 0xff;
            wela = 1;
            P0 = 0xfd;
            wela = 0;
            P0 = 0x00;
            delay(1);
            }


            void delay(uint xms)
            {
            uint i, j;
            for(i = xms; i > 0; i--)
            for(j = 125; j > 0; j--);
            }


            void int_time0() interrupt 1
            {
            TH0 = 0xB8;
            TL0 = 0x00;
            counter++;

            }



            關(guān)鍵詞: 單片機定時器0信號交通

            評論


            技術(shù)專區(qū)

            關(guān)閉