中文字幕 另类精品,亚洲欧美一区二区蜜桃,日本在线精品视频免费,孩交精品乱子片免费

<sup id="3hn2b"></sup>

    1. <sub id="3hn2b"><ol id="3hn2b"></ol></sub><legend id="3hn2b"></legend>

      1. <xmp id="3hn2b"></xmp>

      2. 新聞中心

        EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > MC-51單片機紅綠燈+數(shù)碼管計時實驗

        MC-51單片機紅綠燈+數(shù)碼管計時實驗

        作者: 時間:2016-11-24 來源:網(wǎng)絡(luò) 收藏
        單片機實驗

        //主機板的P1接口 平接 顯示板P00接口 即數(shù)碼管段選接口
        //主機板的P3接口 平接 顯示板P20接口 即數(shù)碼管位選接口
        //主機板的P0接口 平接 顯示板燈的接口

        本文引用地址:http://www.antipu.com.cn/article/201611/320677.htm

        #include
        unsigned char time[10]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
        int n = 2000;//每半秒中斷一次

        bit change=1;
        bit Shan=1;//閃

        //定義顯示管為位選特殊位
        sbit A=P3^7;
        sbit B1=P3^6;
        sbit C=P3^5;
        sbit G1=P3^4;
        sbit daul = P3^3;


        ZY();//左右通行
        SX();//上下通行
        ZYS();//左右綠燈閃
        SXS();//上下綠燈閃

        lock();
        delay();

        //一下定義使燈亮的特殊位
        sbit ZL=P0^0;
        sbit ZH=P0^1;
        sbit SH=P0^2;
        sbit SL=P0^3;
        sbit YH=P0^4;
        sbit YL=P0^5;
        sbit XH=P0^6;
        sbit XL=P0^7;
        //
        unsigned char rl=70;
        unsigned char ud=45;
        unsigned int working=0;//
        unsigned char num;


        main()
        {
        TMOD=2;//設(shè)置定時/計數(shù)器0工作方式2
        TH0=6;//初值為6,定時4000
        TL0=6;//初值為6
        TR0=1;
        ET0=1;
        EA=1;
        working = rl*2;

        while(1){
        if(change==1&&Shan==1){//
        ZY();
        }else if(change==1&&Shan==0){
        ZYS();
        }else if(change==0&&Shan==1){
        SX();
        }else if(change==0&&Shan==0){
        SXS();
        }

        num=working/2;

        P1=time[num];
        daul=1;
        A=1;B1=1;C=1;
        G1=1;
        delay();
        lock();

        P1=time[num/10];
        daul=1;
        A=0;B1=1;C=1;
        G1=1;
        delay();
        lock();

        }

        //
        }


        //中斷程序

        T0_int() interrupt 1{
        n--;
        if(n==0){
        if(working!=0&&change==1){
        if(working<=4){//最后兩秒閃
        Shan=!Shan;
        }
        working--;
        n=2000;
        }else if(working==0&&change==1){
        change=!change;
        working = ud*2;
        n=2000;
        }else if(working!=0&&change==0){
        if(working<=6){//最后3秒閃
        Shan=!Shan;
        }
        working--;
        n=2000;
        }else if(working==0&&change==0){
        change=!change;
        working = rl*2;
        n=2000;
        }
        }
        }

        ZY(){//左右綠燈亮,上下紅燈亮
        YL=0;//右綠
        ZL=0;//左綠
        SH=0;//上紅
        XH=0;//下紅
        //
        ZH=1;
        YH=1;
        SL=1;
        XL=1;
        }

        SX(){//上下綠燈亮,左右紅燈亮
        YL=1;//
        ZL=1;
        SH=1;
        XH=1;
        //
        ZH=0;
        YH=0;
        SL=0;
        XL=0;
        }

        ZYS(){//左右綠燈閃爍
        YL=1;
        ZL=1;
        SH=0;
        XH=0;
        //
        ZH=1;
        YH=1;
        SL=1;
        XL=1;
        }

        SXS(){//上下綠燈閃爍
        YL=1;//
        ZL=1;
        SH=1;
        XH=1;
        //
        ZH=0;
        YH=0;
        SL=1;
        XL=1;
        }

        lock(){
        daul=0;
        G1=0;
        }

        delay(){
        int i=40;
        while(i>0){
        i--;
        }
        }



        評論


        相關(guān)推薦

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

        關(guān)閉