首页 1602液晶显示器的详细控制与应用

1602液晶显示器的详细控制与应用

举报
开通vip

1602液晶显示器的详细控制与应用1602液晶显示器的详细控制与应用 #include #include #define uchar unsigned char #define uint unsigned int uchar SecondLine[]="xxxxxxxx "; //第二行数据 uchar FirstLine[] ="xxxxxxxxx "; //第一行数据 #define Data P1 //数据端口 sbit RS=P2^4; sbit RW=P2^5; sbit E=P2^6; void delay(uchar m...

1602液晶显示器的详细控制与应用
1602液晶显示器的详细控制与应用 #include #include #define uchar unsigned char #define uint unsigned int uchar SecondLine[]="xxxxxxxx "; //第二行数据 uchar FirstLine[] ="xxxxxxxxx "; //第一行数据 #define Data P1 //数据端口 sbit RS=P2^4; sbit RW=P2^5; sbit E=P2^6; void delay(uchar ms) // 延时函数ms毫秒 { uchar i,j; for(i=ms;i>0;i--) for(j=100;j>0;j--); } void DelayUs(unsigned char us) //--延时函数 { unsigned char uscnt; uscnt=us>>1; /*12MHz频率*/ while(--uscnt); } void DelayMs(unsigned char ms) { while(--ms) { DelayUs(250); DelayUs(250); DelayUs(250); DelayUs(250); } } void lcd_write_com(uchar c) //写命令 { DelayMs(5);//操作前短暂延时,保证信号稳定 E=0; RS=0; RW=0; _nop_(); E=1; Data=c; E=0; } void lcd_write_dat(uchar c) //写数据 { DelayMs(5); //操作前短暂延时,保证信号稳定 E=0; RS=1; RW=0; _nop_(); E=1; Data=c; E=0; RS=0; } void lcd_init() //LCD初始化 { DelayMs(15); lcd_write_com(0x38); //display mode lcd_write_com(0x38); //display mode lcd_write_com(0x38); //display mode lcd_write_com(0x06); //显示光标移动位置 lcd_write_com(0x0c); //显示开及光标设置 lcd_write_com(0x01); //显示清屏 } void ShowChar(uchar pos,uchar c) //显示单个字符 { unsigned char p; if (pos>=0x10) p=pos+0xb0; //是第二行则命令代码高4位为0xc else p=pos+0x80; //是第二行则命令代码高4位为0x8 lcd_write_com(p);//写命令 lcd_write_dat(c); //写数据 } void ShowString (uchar line,char *ptr) //显示字符串 { unsigned char l,*p; p=ptr; l=line<<4; while((*p)!='\0') { ShowChar(l++,*(p)); p++; } } void disp(void) //主函数调用的显示函数 { ShowChar(uchar pos,uchar c) ShowString(0,"Jilin University"); ShowString(1,SecondLine); } Void main() { Disp(); While(1); }
本文档为【1602液晶显示器的详细控制与应用】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_105949
暂无简介~
格式:doc
大小:15KB
软件:Word
页数:0
分类:互联网
上传时间:2017-10-17
浏览量:11