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

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

        LCD12864帶中文字庫圖形顯示-單片機程序(多圖)

        作者:佚名   來源:本站原創   點擊數:  更新時間:2014年08月21日   【字體:

        代碼:

        #include <reg52.h>
        #define uchar unsigned char
         
        sbit rs=P2^2;//寫指令/數據
        sbit rw=P2^3;//讀狀態/寫
        sbit e=P2^4;//使能端
        sbit psb=P2^5;//串/并輸入
         
         
        //;
        unsigned char code image[]={
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x00,0x00,0x1F,0xFF,0x80,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x00,0x00,0xFC,0xFF,0xF8,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x00,0x07,0xF4,0xFC,0x7E,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x00,0x0D,0xF0,0xFC,0xFF,0x80,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x00,0x13,0xF0,0x78,0x7F,0xC0,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x00,0x75,0xF7,0xFF,0xFC,0xE0,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x00,0xF8,0xF8,0x00,0xF9,0x78,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x01,0xFD,0xCF,0xFF,0x1E,0xFC,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x03,0xFA,0x3F,0xFF,0x66,0xFE,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x07,0xFD,0xFF,0xFD,0x79,0xFF,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x0E,0xF3,0xFF,0xFA,0xFE,0xF0,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x18,0x2F,0xFF,0xF0,0xFF,0x69,0x80,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x3C,0xDF,0xFF,0xD5,0xFF,0xA3,0xC0,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x3E,0xBF,0xFF,0x93,0xFF,0xDF,0xE0,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x7F,0x7F,0xFF,0x9F,0xFF,0xEF,0xE0,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x7F,0x7E,0x07,0x9F,0x07,0xF7,0xF0,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0xFE,0xFF,0x00,0x00,0x0F,0xF3,0xF0,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x01,0xFD,0xFF,0x80,0x00,0x1F,0xFB,0xF8,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x01,0xFD,0xFF,0xE0,0x00,0x3F,0xFD,0xF8,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x01,0xFB,0xF9,0xE0,0x00,0x79,0xFD,0xFC,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x01,0xFB,0xFC,0x10,0x00,0x81,0xFD,0xFC,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x03,0xFB,0xFE,0x00,0x02,0x03,0xFE,0xFC,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x03,0xF7,0xFE,0x00,0x00,0x07,0xFE,0xFC,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x03,0xF7,0xFF,0x00,0x08,0x0F,0xFE,0xFE,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x03,0xF7,0xF0,0x40,0xF8,0x10,0x7E,0xFE,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x03,0xF7,0xF0,0x00,0x00,0x00,0xFF,0x7E,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x07,0xF7,0xFC,0x00,0x00,0x01,0xFF,0x7E,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x06,0x37,0xFE,0x00,0x00,0x07,0xFF,0x72,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x06,0x77,0xFF,0x80,0x00,0x0F,0xFF,0x5E,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x07,0xF7,0xF3,0xE0,0x00,0x7D,0xFF,0x7E,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x06,0x37,0xFC,0x7F,0x07,0xE1,0xFF,0x5E,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x02,0xF7,0xFE,0xBF,0x07,0xCB,0xFF,0xC6,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x03,0xF7,0xFC,0x1E,0x06,0x1F,0xFE,0xFE,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x02,0x37,0xFD,0x0F,0xD9,0x1F,0xFE,0xC4,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x03,0xFB,0xFE,0x82,0x80,0x3F,0xFE,0xF4,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x03,0x1B,0xFE,0x80,0x00,0x3F,0xFE,0xEC,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x01,0xFB,0xFF,0xC0,0x00,0xFF,0xFD,0xFC,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x01,0xD9,0xFF,0xA8,0x0B,0xFF,0xFD,0xBC,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x01,0xED,0xFF,0xFC,0x0B,0xFF,0xFB,0xE8,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0xEC,0xFF,0xFE,0x8F,0xFF,0xFB,0x28,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0xCE,0xFF,0xFF,0xDF,0xFF,0xF7,0xD0,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x73,0x7F,0xFF,0xDF,0xFF,0xE7,0x30,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x6F,0xBF,0xFE,0x8B,0x23,0xEE,0xE0,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x37,0x9F,0xED,0xFF,0xFF,0xDD,0xC0,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x1F,0xCF,0xBF,0xFF,0xFD,0xBA,0xC0,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x1E,0xE5,0x7F,0xFF,0xFE,0x79,0x80,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x0D,0x7B,0xFE,0x63,0xFC,0xDB,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x06,0x3C,0xFE,0x27,0xF3,0xFE,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x03,0x5F,0x1F,0xFF,0xCF,0x5C,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x01,0xEB,0xE3,0xFC,0x3C,0x78,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x00,0xDB,0xFC,0x03,0xFB,0x30,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x00,0x3E,0xDF,0xFF,0x9D,0xE0,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x00,0x1F,0xBB,0xFC,0xFD,0xC0,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x00,0x0F,0xAA,0xBE,0xBF,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x00,0x03,0xEE,0xBE,0xBC,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x00,0x00,0x7E,0x9F,0xF0,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x00,0x00,0x0F,0xFF,0x00,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
         
         
         
         
        };
         
        void delay(int i)
        {
        uchar j;
        while(i--)
        for(j=110;j>0;j--);
        }
        //讀狀態,檢測忙
        void check_busy()
        {
        rs=0;
        rw=1;
        e=1;
        P0=0xff;
        while((P0&0x80)==0x80);
        e=0;
        }
        //寫指令
        void write_com(uchar com)
        {
        check_busy();
        rs=0;
        rw=0;
        e=1;
        P0=com;
        delay(5);
        e=0;
        delay(5);
        }
        //寫數據
        void write_data(uchar _data)
        {
        check_busy();
        rs=1;
        rw=0;
        e=1;
        P0=_data;
        delay(5);
        e=0;
        delay(5);
        }
        //初始化lcd
        void init()
        {
        rw=0;
        psb=1;//選擇為并行輸入
        delay(50);
        write_com(0x30);//基本指令操作
        delay(5);
        write_com(0x0c);//顯示開,關光標
        delay(5);
        write_com(0x06);//寫入一個字符,地址加1
        delay(5);
        write_com(0x01);
        delay(5);
         
        }
         
        void wstring(uchar *str)
        {
        while(*str)
        {
        write_data(*str);
        delay(5);
        str++;
        }
        }
        void lcd_draw(unsigned char code *pic)
        {
        unsigned i,j,k;
        write_com(0x34);//擴充指令集
         
        for(i=0;i<2;i++)//上半屏和下半屏
        {
        for(j=0;j<32;j++)//上下半屏各32行
        {
        write_com(0x80+j);//寫行地址(y地址)
        if(i==0)
        {
        write_com(0x80);//寫列地址(x地址),上半屏列地址為0x80,下半屏列地址為0x88
        }
        else
        {
        write_com(0x88);
        }
        for(k=0;k<16;k++)//寫入列數據
        {
        write_data(*pic++);
        }
        }
        }
         
         
        write_com(0x36);//顯示圖形
        write_com(0x30);//基本指令集
         
        }
         
         
         
        void main()
        {
        init();
        write_com(0x80);//第一行地址
        wstring("北京理工大學珠海");
         
         
        write_com(0x90);//第二行地址
        wstring("學院");
         
         
        write_com(0x98);//第三行地址
        wstring("www.zhbit.com");/**/
         
        delay(5000);
        write_com(0x01);
         
        write_com(0x80);
        wstring("ZHUHAI CAMPUS,");
         
        write_com(0x90);
        wstring("BEIJING ");
         
        write_com(0x88);
        wstring("INSTITUTE OF ");
         
        write_com(0x98);
        wstring("TECHNOLOGY");
         
         
        delay(5000);
        write_com(0x01);
         
        lcd_draw(image);
         
        write_com(0x98+5);
        wstring("ZHBIT");
         
        while(1);
         
         
        }

        lcd比數碼管好玩多

        效果:
        ;张貌惶







        繪圖更好的一個算法:(可以繪分塊,也可繪全屏)
        void lcd_block(char num,char flag)
        {
        //x1:列數,yl:行數,x:列坐標,
        //sx:該圖形距離第一幅圖的距離
        //此函數也可以用來畫全屏圖
        unsigned i,j,k,xl,yl,x,y,sx;
        unsigned char code *pic;
         
        switch(num)
        {
        case 0: j=0; pic=image0;xl=5;yl=12;sx=3;x=0x80|sx;break;
        case 1: j=13;pic=image4;xl=4;yl=37;sx=0;x=0x80|sx;break;
        case 2: j=13;pic=image4;xl=4;yl=37;sx=3;x=0x80|sx;break;
        case 3: j=13;pic=image4;xl=4;yl=12;sx=6;x=0x80|sx;break;
        case 4: j=7; pic=image4;xl=4;yl=31;sx=0;x=0x88|sx;break;
        case 5: j=7; pic=image5;xl=4;yl=31;sx=3;x=0x88|sx;break;
        case 6: j=7; pic=image5;xl=4;yl=31;sx=6;x=0x88|sx;break;
        case 7: j=0; pic=image7;xl=16;yl=64;sx=0;x=0x80|sx;break;
        }
        write_com(0x34);
        for(j;j<yl;j++)
        {
        if(j>31) {y=j-32;x=0x88|sx;}
        else y=j;
        write_com(0x80+y);
        write_com(x);
        for(k=0;k<xl;k++)
        {
        if(flag)
        write_data(*pic++);
        else write_data(~(*pic++));
        }
        }
        /* for(j;j<yl;j++)
        {
        write_com(0x80+j);
        write_com(x);
        for(k=0;k<xl;k++)
        {
        if(flag)
        write_data(*pic++);
        else write_data(~(*pic++));
        }
        }*/
         
        write_com(0x36); //顯示圖形
        write_com(0x30); //基本指令集
        }
        關閉窗口
        欧美性色欧美精品视频,99热这里只有精品mp4,日韩高清亚洲日韩精品一区二区,2020国自产拍精品高潮