<acronym id="xonnx"></acronym>
      <td id="xonnx"></td>
    1. <pre id="xonnx"></pre>

      1. 專注電子技術學習與研究
        當前位置:單片機教程網 >> MCU設計實例 >> 瀏覽文章

        基于12864液晶的程序代碼顯示本人姓名及專業

        作者:huqin   來源:本站原創   點擊數:  更新時間:2014年04月04日   【字體:




        #include"reg51.h"
        #define uchar unsigned char
        #define uint unsigned int
        sbit lcdrst=P3^0;
        sbit cs2=P3^5;
        sbit cs1=P3^4;
        sbit e=P3^2;
        sbit rw=P3^3;
        sbit rs=P3^1;
        uchar code liu[]={0x00,0x08,0x28,0x49,0x8A,0x0C,0xC8,0x38,0x08,0x00,0xF8,0x00,0x00,0xFF,0x00,0x00,
        0x40,0x20,0x10,0x08,0x04,0x03,0x06,0x38,0x10,0x00,0x07,0x20,0x40,0x3F,0x00,0x00};
        uchar code xiao[]={0x08,0x88,0x68,0xFF,0x28,0x48,0x00,0x88,0x68,0x09,0x0E,0x08,0xA8,0x48,0x88,0x00,
        0x02,0x01,0x00,0xFF,0x00,0x40,0x42,0x21,0x26,0x18,0x18,0x26,0x61,0xC0,0x40,0x00};
        uchar code jun[]={0x00,0x18,0x26,0x22,0xA2,0x72,0x2E,0xAA,0x22,0x22,0x22,0x32,0x22,0x0A,0x06,0x00,
        0x00,0x10,0x10,0x12,0x13,0x12,0x12,0xFF,0x12,0x12,0x12,0x13,0x12,0x18,0x10,0x00};
        uchar code dian[]={0x00,0x00,0xF8,0x48,0x48,0x48,0x48,0xFF,0x48,0x48,0x48,0x48,0xF8,0x00,0x00,0x00,
        0x00,0x00,0x0F,0x04,0x04,0x04,0x04,0x3F,0x44,0x44,0x44,0x44,0x4F,0x40,0x70,0x00};
        uchar code zi[]={0x00,0x00,0x02,0x02,0x02,0x02,0x02,0xE2,0x12,0x0A,0x06,0x02,0x00,0x80,0x00,0x00,
        0x01,0x01,0x01,0x01,0x01,0x41,0x81,0x7F,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00};
        uchar code xin[]={0x80,0x40,0x30,0xFC,0x07,0x0A,0xA8,0xA8,0xA9,0xAE,0xAA,0xA8,0xA8,0x08,0x08,0x00,
        0x00,0x00,0x00,0x7F,0x00,0x00,0x7E,0x22,0x22,0x22,0x22,0x22,0x7E,0x00,0x00,0x00};
        uchar code xi[]={0x00,0x00,0x00,0xFC,0x54,0x54,0x56,0x55,0x54,0x54,0x54,0xFC,0x00,0x00,0x00,0x00,
        0x00,0x20,0x38,0x01,0x3D,0x41,0x41,0x45,0x59,0x41,0x41,0x71,0x00,0x08,0x30,0x00};
        uchar code gong[]={0x00,0x00,0x02,0x02,0x02,0x02,0x02,0xFE,0x02,0x02,0x02,0x02,0x02,0x02,0x00,0x00,
        0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00};
        uchar code cheng[]={0x10,0x12,0xD2,0xFE,0x91,0x11,0x80,0xBF,0xA1,0xA1,0xA1,0xA1,0xBF,0x80,
        0x00,0x00,0x04,0x03,0x00,0xFF,0x00,0x41,0x44,0x44,0x44,0x7F,0x44,0x44,0x44,0x44,0x40,0x00};
        uchar code zhuan[]={0x20,0x20,0x24,0x24,0xA4,0x64,0x3C,0x27,0x24,0x24,0xA4,0x24,0x24,0x20,0x20,0x00,
        0x00,0x00,0x00,0x00,0x01,0x01,0x09,0x11,0x29,0x45,0x03,0x01,0x00,0x00,0x00,0x00};
        uchar code ye[]={0x00,0x10,0x60,0x80,0x00,0xFF,0x00,0x00,0x00,0xFF,0x00,0x80,0x60,0x38,0x10,0x00,
        0x20,0x20,0x20,0x23,0x21,0x3F,0x20,0x20,0x20,0x3F,0x22,0x21,0x20,0x30,0x20,0x00};

        uchar code wu[]={0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00};
        uchar code er[]={0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00};
        uchar code ling[]={0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00};
        uchar code kongge[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
        uchar code kong[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
        /*uchar code xing[]={0x20,0x24,0x2C,0x35,0xE6,0x34,0x2C,0x24,0x00,0xFC,0x24,0x24,0xE2,0x22,0x22,0x00,
        0x21,0x11,0x4D,0x81,0x7F,0x05,0x59,0x21,0x18,0x07,0x00,0x00,0xFF,0x00,0x00,0x00};
        uchar code de[]={0x00,0xF8,0x8C,0x8B,0x88,0xF8,0x40,0x30,0x8F,0x08,0x08,0x08,0x08,0xF8,0x00,0x00,
        0x00,0x7F,0x10,0x10,0x10,0x3F,0x00,0x00,0x00,0x03,0x26,0x40,0x20,0x1F,0x00,0x00};
        uchar code yi[]={0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xC0,0x80,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
        uchar code nian[]={0x40,0x20,0x10,0x0C,0xE3,0x22,0x22,0x22,0xFE,0x22,0x22,0x22,0x22,0x02,0x00,0x00,
        0x04,0x04,0x04,0x04,0x07,0x04,0x04,0x04,0xFF,0x04,0x04,0x04,0x04,0x04,0x04,0x00}; */
        uchar code zhu[]={0x08,0x08,0x89,0xCE,0xA8,0x18,0x00,0xFE,0x82,0x82,0x82,0x82,0xFE,0x00,0x00,0x00,
        0x02,0x01,0x00,0xFF,0x00,0x83,0x40,0x30,0x0F,0x00,0x00,0x7F,0x80,0x80,0xF0,0x00};
        uchar code yuan[]={0x00,0x00,0xFF,0x01,0x01,0x7D,0x55,0x57,0x55,0xD5,0x55,0x55,0x7D,0x01,0x01,0x00,
        0x20,0x18,0x07,0x20,0x3A,0x02,0x39,0x40,0x4A,0x57,0x40,0x60,0x01,0x0A,0x30,0x00};
        uchar code da[]={0x20,0x20,0x20,0x20,0x20,0x20,0xA0,0x7F,0xA0,0x20,0x20,0x20,0x20,0x20,0x20,0x00,
        0x00,0x80,0x40,0x20,0x10,0x0C,0x03,0x00,0x01,0x06,0x08,0x30,0x60,0xC0,0x40,0x00};
        uchar code jia[]={0x00,0x18,0x04,0x14,0x94,0x94,0xD5,0xB6,0x14,0x14,0x94,0x04,0x14,0x0C,0x04,0x00,
        0x00,0x29,0x29,0x15,0x14,0x4A,0x89,0x44,0x3F,0x06,0x09,0x09,0x10,0x30,0x10,0x00};
        uchar code jie[]={0x04,0x04,0x44,0x44,0x44,0x5F,0xC4,0x44,0x44,0x44,0x5F,0x44,0xC4,0x04,0x04,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x08,0x10,0x0F,0x00,0x00,0x00};
        uchar code ri[]={0x00,0x00,0x00,0xFE,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0xFE,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x3F,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x3F,0x00,0x00,0x00,0x00};
        uchar code kuai[]={0x70,0x00,0xFF,0x08,0xB0,0x88,0x88,0x88,0xFF,0x88,0x88,0x88,0xF8,0x80,0x80,0x00,
        0x00,0x00,0xFF,0x00,0x80,0x40,0x30,0x0E,0x01,0x06,0x08,0x30,0x60,0xC0,0x40,0x00};
        uchar code le[]={0x00,0x00,0x40,0xFC,0x44,0x44,0x44,0x46,0xFA,0x42,0x43,0x43,0x42,0x40,0x00,0x00,
        0x00,0x20,0x18,0x0C,0x07,0x12,0x20,0x40,0x3F,0x00,0x00,0x02,0x0C,0x38,0x10,0x00};
        void delay(uchar z)
        {
        uchar i,j;
        for(i=z;i>0;i--)
        for(j=110;j>0;j--);
        }
        void checkbusy()
        {
        uchar dat;
        rs=0; //數據\指令選擇
        rw=1; //允許讀
        do
        {
        P2=0x00; //清零P2口
        delay(5);
        e=1;
        dat=P2; //讀P2口
        e=0;
        dat>>=7; //僅當第7位為0時才可操作(判別busy信號)
        }
        while(!(dat==0x00));
        }
        void write_com(uchar com)
        {
        checkbusy(); //檢查是否忙
        rs=0; //寫命令
        rw=0;
        P2=com;
        e=1;
        e=0;
        }
        void write_data(uchar date)
        {
        checkbusy(); //檢查是否忙
        rs=1; //寫數據
        rw=0;
        P2=date;
        e=1;
        e=0;
        }
        void hanzi(uchar ye,uchar lie,uchar *daima)
        {
        uchar i,j;
        for(i=0;i<2;i++)
        {
        write_com(0xb8+ye+i); // ye頁與 ye+1頁
        write_com(0x40+lie); //確定初始行
        for(j=0;j<16;j++)
        {
        write_data(daima[i*16+j]); //寫數據(漢字)
        }
        }
        }
        void shuzi(uchar ye,uchar lie,uchar *daima)
        {
        uchar i,j;
        for(i=0;i<2;i++)
        {
        write_com(0xb8+ye+i); // ye頁與 ye+1頁
        write_com(0x40+lie); //確定初始行
        for(j=0;j<8;j++)
        {
        write_data(daima[i*8+j]); //寫數據(數字)
        }
        }
        }
        void clearlcd()
        {
        uchar i,j;
        cs1=0; //清全屏 有cs1=0 cs2=0 與無 cs1=0 cs2=0 效果不同
        cs2=0;
        for(i=0;i<8;i++)
        {
        write_com(0xb8+i);
        write_com(0x40);
        for(j=0;j<64;j++)
        write_data(0x00);
        }
        }
        void init()
        {
        write_com(0x3e); //關顯示
        delay(1);
        write_com(0x3f); //開顯示
        write_com(0xc0); //行初始地址
        write_com(0xb8); //頁初始地址
        write_com(0x40); //列初始地址
        }
        void display()
        {
        cs1=0; //左半屏 cs1=0 cs2=1
        cs2=1;
        hanzi(0,0,liu);
        hanzi(0,16,xiao);
        hanzi(0,32,jun);
        hanzi(0,48,dian);
        cs1=1; //右半屏 cs1=1 cs2=0
        cs2=0;
        hanzi(0,0,zi);
        hanzi(0,16,xin);
        //hanzi(0,32,kongge); // 如果清屏時加上cs1=0 cs2=0則可以不用,否則要加上
        //hanzi(0,48,kongge);
        cs1=0;
        cs2=1;
        hanzi(2,0,xi);
        hanzi(2,16,gong);
        hanzi(2,32,cheng);
        hanzi(2,48,zhuan);
        cs1=1;
        cs2=0;
        hanzi(2,0,ye);
        //hanzi(2,16,wang);
        //hanzi(2,32,kongge);
        //hanzi(2,48,kongge);
        cs1=0;
        cs2=1;
        shuzi(4,0,wu);
        shuzi(4,8,er);
        shuzi(4,16,ling);
        //hanzi(4,32,zhu);
        hanzi(4,32,zhu);
        hanzi(4,48,yuan);
        cs1=1;
        cs2=0;
        hanzi(4,0,da);
        shuzi(4,16,jia);
        //hanzi(4,24,jia);
        //hanzi(4,40,kongge);
        shuzi(4,56,kong);
        cs1=0;
        cs2=1;
        //hanzi(6,0,jia);
        hanzi(6,0,jie);
        hanzi(6,16,ri);
        hanzi(6,32,kuai);
        hanzi(6,48,le);
        cs1=1;
        cs2=0;
        //hanzi(6,0,kongge);
        //hanzi(6,16,kongge);
        //hanzi(6,32,kongge);
        //hanzi(6,48,kongge);
        }
        void main()
        {
        init();
        clearlcd();
        while(1)
        {
        display();
        }
        }

        關閉窗口

        相關文章

        欧美性色欧美精品视频,99热这里只有精品mp4,日韩高清亚洲日韩精品一区二区,2020国自产拍精品高潮