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

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

        LCD1602液晶顯示漢字顯示程序帶仿真

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

         //建立“工”字字模并在第一行第一列顯示

        //P155 參考程序: GONG_ZI()
        //單片機仿真文件下載:http://www.thefapper.com/bbs/dpj-23789-1.html 
        #include <reg51.h>
        #include <intrins.h>   //庫函數頭文件,代碼中引用了_nop_()函數
        sbit RS=0xb0; //P3.0
        sbit RW=0xb1; //P3.1
        sbit E= 0xb2; //P3.2
        void lcd_w_cmd(unsigned char com);
        void lcd_w_dat(unsigned char dat);
        unsigned char lcd_r_start();
        void int1();
        void delay(unsigned char t);
        void delay1();
        void main()
        {
        P2=0xff;
        int1();
        lcd_w_cmd(0x40); //工
        lcd_w_dat(0x1f);
        lcd_w_cmd(0x41);
        lcd_w_dat(0x1f);
        lcd_w_cmd(0x42);
        lcd_w_dat(0x04);
        lcd_w_cmd(0x43);
        lcd_w_dat(0x04);
        lcd_w_cmd(0x44);
        lcd_w_dat(0x04);
        lcd_w_cmd(0x45);
        lcd_w_dat(0x1f);
        lcd_w_cmd(0x46);
        lcd_w_dat(0x1f);
        lcd_w_cmd(0x47);
        lcd_w_dat(0x00);
        lcd_w_cmd(0x48); //欠
        lcd_w_dat(0x08);
        lcd_w_cmd(0x49);
        lcd_w_dat(0x0f);
        lcd_w_cmd(0x4a);
        lcd_w_dat(0x0d);
        lcd_w_cmd(0x4b);
        lcd_w_dat(0x14);
        lcd_w_cmd(0x4c);
        lcd_w_dat(0x04);
        lcd_w_cmd(0x4d);
        lcd_w_dat(0x0a);
        lcd_w_cmd(0x4e);
        lcd_w_dat(0x11);
        lcd_w_cmd(0x4f);
        lcd_w_dat(0x00);
        lcd_w_cmd(0x50); //又
        lcd_w_dat(0x00);
        lcd_w_cmd(0x51);
        lcd_w_dat(0x0e);
        lcd_w_cmd(0x52);
        lcd_w_dat(0x02);
        lcd_w_cmd(0x53);
        lcd_w_dat(0x0a);
        lcd_w_cmd(0x54);
        lcd_w_dat(0x04);
        lcd_w_cmd(0x55);
        lcd_w_dat(0x0a);
        lcd_w_cmd(0x56);
        lcd_w_dat(0x11);
        lcd_w_cmd(0x57);
        lcd_w_dat(0x00);
        lcd_w_cmd(0x80);
        lcd_w_dat(0x00);
        lcd_w_cmd(0xc0);
        lcd_w_dat(0x02);
        lcd_w_dat(0x01);
        while(1);
        }
        void delay(unsigned char t)
        {
        unsigned char j,i;
        for(i=0;i<t;i++)
        for(j=0;j<50;j++);
        }
        void delay1()
        {
        _nop_();
        _nop_();
        _nop_();
        }
        void int1()
        {
        lcd_w_cmd(0x3c);
        lcd_w_cmd(0x0c);
        lcd_w_cmd(0x01);
        lcd_w_cmd(0x06);
        lcd_w_cmd(0x80);
        }
        unsigned char lcd_r_start()
        {
        unsigned char s;
        RW=1;
        delay1();
        RS=0;
        delay1();
        E=1;
        delay1();
        s=P2;
        delay1();
        E=0;
        delay1();
        RW=0;
        delay1();
        return(s);
        }
        void lcd_w_cmd(unsigned char com)
        {
        unsigned char i;
        do{
        i=lcd_r_start();
        i=i&0x80;
        delay(2);
        }while(i!=0);
        RW=0;
        delay1();
        RS=0;
        delay1();
        E=1;
        delay1();
        P2=com;
        delay1();
        E=0;
        delay1();
        RW=1;
        delay(255);
        }
        void lcd_w_dat(unsigned char dat)
        {
        unsigned char i;
        do{
        i=lcd_r_start();
        i=i&0x80;
        delay(2);
        }while(i!=0);
        RW=0;
        delay1();
        RS=1;
        delay1();
        E=1;
        delay1();
        P2=dat;
        delay1();
        E=0;
        delay1();
        RW=1;
        delay(255);
        }
        關閉窗口

        相關文章

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