新聞中心

        EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 基于單片機的電子萬年歷

        基于單片機的電子萬年歷

        作者: 時間:2016-11-30 來源:網(wǎng)絡(luò) 收藏


        #include
        #define uchar unsigned char
        #define uint unsigned int
        sbit dula=P3^7;
        sbit wela=P2;
        sbit rs=P2^5;
        sbit rw=P2^6;
        sbit s1=P1^0;
        sbit s2=P1^1;
        sbit s3=P1^2;
        sbit rd=P1^7;
        sbit lcden=P2^7;
        uchar count,s1num;
        char shi,fen,miao;
        uchar code table[]=" 2013-4-19 FRI" ;
        uchar code table1[]=" 00:00:00";
        void delay(uint z) 延時函數(shù) delay(5)就是5ms
        {
        uint x,y;
        for(x=z;x>0;x--)
        for(y=110;y>0;y--);
        }
        void write_com(uchar com)
        {
        rs=0;
        rw=0;
        lcden=0;
        P0=com;
        delay(5);
        lcden=1;
        delay(5);
        lcden=0;
        }
        void write_data(uchar date)
        {
        rs=1;
        rw=0;
        lcden=0;
        P0=date;
        delay(5);
        lcden=1;
        delay(5);
        lcden=0;
        }
        void init()
        {
        uchar num;
        dula=0;
        lcden=0;
        rd=0;
        // fen=59;
        // miao=53;
        // shi=23;
        write_com(0x38);
        write_com(0x0c);
        write_com(0x06);
        write_com(0x01);
        write_com(0x80);
        for(num=0;num<15;num++)
        {
        write_data(table[num]);
        delay(5);
        }
        write_com(0x80+0x40);
        for(num=0;num<11;num++)
        {
        write_data(table1[num]);
        delay(5);
        }
        TMOD=0x01;
        TH0=0x4c;
        TL0=0x00;
        EA=1;
        ET0=1;
        TR0=1;

        本文引用地址:http://www.104case.com/article/201611/323922.htm


        上一頁 1 2 3 下一頁

        關(guān)鍵詞: 單片機電子萬年

        評論


        相關(guān)推薦

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

        關(guān)閉
        主站蜘蛛池模板: 宽城| 酉阳| 廊坊市| 连南| 论坛| 苍梧县| 彭山县| 宕昌县| 革吉县| 镇赉县| 论坛| 定陶县| 黑河市| 崇明县| 抚远县| 邢台县| 旬阳县| 成都市| 许昌市| 福州市| 宁河县| 万山特区| 丹凤县| 罗山县| 关岭| 仁寿县| 新沂市| 普安县| 大丰市| 赤水市| 准格尔旗| 西和县| 泊头市| 安徽省| 双桥区| 丹寨县| 紫阳县| 介休市| 四子王旗| 泰州市| 凌海市|