欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標(biāo)題: LCD1602自定義漢字與動態(tài)顯示的應(yīng)用 [打印本頁]

作者: jinsheng7533967    時間: 2018-12-21 03:52
標(biāo)題: LCD1602自定義漢字與動態(tài)顯示的應(yīng)用


  1. #include<reg51.h>        

  2. #define uchar        unsigned char
  3. #define uint  unsigned int

  4. sbit RS = P2^5;
  5. sbit RW = P2^6;
  6. sbit EN = P2^7;

  7. uchar Data2[15]="jinsheng7533967";

  8. //---------自定義的字符數(shù)據(jù)------
  9. uchar code CGCODE[]={
  10. 0x08,0x0f,0x12,0x0f,0x0a,0x1f,0x02,0x02,//顯示年0x00
  11. 0x0F,0x09,0x0F,0x09,0x0F,0x09,0x13,0x00,//顯示月0x01
  12. 0x0F,0x09,0x09,0x0f,0x09,0x09,0x0f,0x00 //顯示日0x02
  13. };


  14. void delay(uint mS);
  15. void User_def(void);

  16. bit BUSY(void);
  17. void Write_cmd(uchar cmd);
  18. void Write_dat(uchar dat);
  19. void LCD_Init(void);

  20. void main(void)
  21. {
  22.         uchar i;
  23.         LCD_Init();
  24.         User_def();                                            //將自定義的字符寫入CGRAM
  25.         while(1)
  26.         {
  27.                 Write_cmd(0x83);
  28.                 Write_dat(0x32);                        //      2
  29.                 Write_dat(0x30);                        //      0
  30.                 Write_dat(0x31);                        //      1
  31.                 Write_dat(0x38);                        //      8
  32.                 Write_dat(0x00);                        //顯示  年               
  33.                 Write_dat(0x31);                        //      1
  34.                 Write_dat(0x32);                        //      2
  35.                 Write_dat(0x01);               
  36.                 Write_dat(0x31);               
  37.                 Write_dat(0x31);               
  38.                 Write_dat(0x02);                        
  39.                 Write_cmd(0xc3);
  40.                 Write_dat(0x02);
  41.                 Write_dat(0x31);                        

  42.                 Write_cmd(0xc1);
  43.                 for(i=0;i<15;i++)
  44.                         Write_dat(Data2[i]);
  45.                         delay(200);
  46.                                                                
  47.         }        
  48. }


  49. void delay(uint mS)
  50. {
  51.         uint x,y;
  52.         for(x=mS;x>0;x--)
  53.                 for(y=124;y>0;y--);
  54. }


  55. bit BUSY(void)
  56. {
  57.         bit Bit;
  58.         RS = 0;
  59.         RW = 1;
  60.         EN = 1;
  61.         delay(1);
  62.         Bit = (bit)(P0 & 0x80);        //最高位為忙信號位        
  63.         EN = 0;
  64.         return Bit;                                
  65. }


  66. void Write_cmd(uchar cmd)
  67. {
  68.         while(BUSY());                        //測忙
  69.         RS = 0;
  70.         RW = 0;
  71.         EN = 0;        
  72.         P0 = cmd;
  73.         EN = 1;
  74.         delay(1);
  75.         EN = 0;                        
  76. }
復(fù)制代碼

  完整代碼附件中


LCD1602自定義漢字與動態(tài)顯示的應(yīng)用.rar (13.95 KB, 下載次數(shù): 58)





作者: zhangsisi    時間: 2018-12-25 15:29
文件打不開????

作者: w358435135    時間: 2018-12-25 18:27
文件不全啊
user_def()函數(shù)沒啊

作者: jinsheng7533967    時間: 2019-1-13 04:38
w358435135 發(fā)表于 2018-12-25 18:27
文件不全啊
user_def()函數(shù)沒啊

下面是重新修整過的代碼,此例的目地是讓他家了解一下LCD1602動態(tài)顯示


#include<reg51.h>               
#define uchar        unsigned char
#define uint    unsigned int

sbit RS = P2^5;
sbit RW = P2^6;
sbit EN = P2^7;

uchar Data2[15]="jinsheng7533967";

//---------自定義的字符數(shù)據(jù)------
uchar code CGCODE[]={
0x08,0x0f,0x12,0x0f,0x0a,0x1f,0x02,0x02,//顯示年0x00
0x0F,0x09,0x0F,0x09,0x0F,0x09,0x13,0x00,//顯示月0x01
0x0F,0x09,0x09,0x0f,0x09,0x09,0x0f,0x00 //顯示日0x02
};

//-----------函數(shù)的聲明------------------
void DelayMS(uint dly);
void User_def(void);

//----------液晶模塊的聲明---------------
bit BUSY(void);
void Write_cmd(uchar cmd);
void Write_dat(uchar dat);
void LCD_Init(void);


void main(void)
{
        uchar i, k;
        LCD_Init();
        User_def();                                            //將自定義的字符寫入CGRAM
        while(1)
        {
                Write_cmd(0x83);
                Write_dat(0x32);                        //      2
                Write_dat(0x30);                        //      0
                Write_dat(0x31);                        //      1
                Write_dat(0x38);                        //      8
                Write_dat(0x00);                        //顯示  年               
                Write_dat(0x31);                        //      1
                Write_dat(0x32);                        //      2
                Write_dat(0x01);                        //顯示  月
                Write_dat(0x31);               
                Write_dat(0x31);                       
                Write_dat(0x02);                       
                Write_cmd(0xc3);
                Write_dat(0x02);
                Write_dat(0x31);                       

                Write_cmd(0xc1);
                for(i=0;i<15;i++)
                        Write_dat(Data2);
                Write_cmd(0x8b);       
                Write_dat(0x30+k/10);       
                Write_dat(0x31+k%10);       
                DelayMS(200);        DelayMS(200);        DelayMS(200);       
                if(k>30)k=0;
        else        k++;                                                                       
        }       
}


void DelayMS(uint dly)
{
        uint x,y;
        for(x=dly;x>0;x--)
                for(y=124;y>0;y--);
}


bit BUSY(void)
{
        bit Bit;
        RS = 0;
        RW = 1;
        EN = 1;
        DelayMS(1);
        Bit = (bit)(P0 & 0x80);        //最高位為忙信號位       
        EN = 0;
        return Bit;                               
}


void Write_cmd(uchar cmd)
{
        while(BUSY());                        //測忙
        RS = 0;
        RW = 0;
        EN = 0;       
        P0 = cmd;
        EN = 1;
        DelayMS(1);
        EN = 0;                       
}

void Write_dat(uchar dat)
{
        while(BUSY());                        //測忙
        RS = 1;
        RW = 0;
        EN = 0;       
        P0 = dat;
        EN = 1;
        DelayMS(1);
        EN = 0;                       
}


void LCD_Init(void)
{
        Write_cmd(0x38);                        //功能設(shè)置
        DelayMS(1);
        Write_cmd(0x0c);                        //顯示開關(guān)控制
        DelayMS(1);
        Write_cmd(0x06);                        //輸入方式設(shè)置
        DelayMS(1);
        Write_cmd(0x01);                        //清除LCD的顯示內(nèi)容
        DelayMS(1);
}

void User_def(void)
{       
        uchar i;
        Write_cmd(0x40);                        //設(shè)置CGRAM地址
        for(i=0;i<24;i++)
        {
                Write_dat(CGCODE);
        }                               
}



作者: zhengchong60    時間: 2019-1-28 16:53
很好很好,借用一下咯!呵呵!
作者: sheng7533967    時間: 2019-2-13 16:43
謝謝分享!實力超強!
作者: 猶豫的流星    時間: 2019-3-19 10:13
1602顯示漢字比較勉強啊
作者: 盛世流年    時間: 2019-3-23 10:54
謝謝分享




歡迎光臨 (http://www.raoushi.com/bbs/) Powered by Discuz! X3.1