|
QQ截圖20181221034253.jpg (404.84 KB, 下載次數(shù): 60)
下載附件
2018-12-21 03:44 上傳
- #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
- };
- void delay(uint mS);
- 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;
- 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[i]);
- delay(200);
-
- }
- }
- void delay(uint mS)
- {
- uint x,y;
- for(x=mS;x>0;x--)
- for(y=124;y>0;y--);
- }
- bit BUSY(void)
- {
- bit Bit;
- RS = 0;
- RW = 1;
- EN = 1;
- delay(1);
- Bit = (bit)(P0 & 0x80); //最高位為忙信號(hào)位
- EN = 0;
- return Bit;
- }
- void Write_cmd(uchar cmd)
- {
- while(BUSY()); //測(cè)忙
- RS = 0;
- RW = 0;
- EN = 0;
- P0 = cmd;
- EN = 1;
- delay(1);
- EN = 0;
- }
復(fù)制代碼
完整代碼附件中
LCD1602自定義漢字與動(dòng)態(tài)顯示的應(yīng)用.rar
(13.95 KB, 下載次數(shù): 58)
2018-12-21 03:52 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
|
評(píng)分
-
查看全部評(píng)分
|