在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,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首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 百米計(jì)時(shí)器LCD1602顯示

            百米計(jì)時(shí)器LCD1602顯示

            作者: 時(shí)間:2016-11-21 來(lái)源:網(wǎng)絡(luò) 收藏
            #include
            #include
            #define uchar unsigned char
            #define uint unsigned int
            sbit k1=P3^0;
            sbit k2=P3^1;
            sbit k3=P3^2;
            sbit k4=P3^3;
            sbit k5=P3^4;
            sbit k6=P3^5;
            sbit k7=P3^6;
            sbit k8=P3^7;
            sbit rs=P2^6;
            sbit rw=P2^5;
            sbit en=P2^7;
            uchar count;
            uint tim;
            void usdelay()
            {
            _nop_();_nop_();
            _nop_();_nop_();
            _nop_();_nop_();
            }
            void delayms(uint z)
            {
            uint x,y;
            for(x=z;x>0;x--)
            for(y=110;y>0;y--);
            }
            void write_com(uchar com)
            {
            rw=0;
            rs=0;
            en=0;
            P0=com;
            delayms(2);
            en=1;
            delayms(2);
            en=0;
            delayms(2);
            }
            void write_dat(uchar dat)
            {
            rw=0;
            rs=1;
            en=0;
            P0=dat;
            delayms(2);
            en=1;
            delayms(2);
            en=0;
            delayms(2);
            }
            void write_zfc(uchar *p)
            {
            while(*p!=0)
            write_dat(*p++);
            }
            void init_1602()
            {
            write_com(0x38);
            write_com(0x0c);
            write_com(0x06);
            write_com(0x01);
            write_com(0x80+1);
            write_zfc("sec : .");
            write_com(0x80+12);
            write_dat(S);
            write_com(0x80+0x40+1);
            write_zfc("the last:");
            }
            void display()
            {
            uchar wan,qian,bai,shi,ge;
            wan=tim/10000;
            qian=(tim-wan*10000)/1000;
            bai=(tim-wan*10000-qian*1000)/100;
            shi=(tim-wan*10000-qian*1000-bai*100)/10;
            ge=tim;
            write_com(0x80+6);
            write_dat(0x30+bai);
            write_dat(0x30+shi);
            write_com(0x80+9);
            write_dat(0x30+ge);
            }
            void display111()
            {
            uchar wan,qian,bai,shi,ge;
            wan=tim/10000;
            qian=(tim-wan*10000)/1000;
            bai=(tim-wan*10000-qian*1000)/100;
            shi=(tim-wan*10000-qian*1000-bai*100)/10;
            ge=tim;
            write_com(0x80+0x40+10);
            write_dat(0x30+bai);
            write_dat(0x30+shi);
            write_com(0x80+0x40+12);
            write_dat(.);
            write_com(0x80+0x40+13);
            write_dat(0x30+ge);
            }
            void main()
            {
            init_1602();
            TMOD=0x01;
            TH0=(65536-50000)/256;
            TL0=(65536-50000)%6;
            EA=1;
            ET0=1;
            TR0=1;
            display();
            while(1)
            {
            if(k3==0)
            display111();
            if(k7==0)
            {
            delayms(50);
            TR0=~TR0;
            }
            if(count==2)
            {
            count=0;
            tim++;
            }
            display();
            }
            }
            void timer0() interrupt 1
            {
            TH0=(65536-50000)/256;
            TL0=(65536-50000)%6;
            count++;
            }



            評(píng)論


            技術(shù)專(zhuān)區(qū)

            關(guān)閉