《单片机液晶显示(以1602为例).pdf》由会员分享,可在线阅读,更多相关《单片机液晶显示(以1602为例).pdf(9页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、液晶显示(所有程序都经过测试合格)一、基础部分。(以 1602 与 12864 介绍)本部分以液晶1602 为主,来引出关于单片机操作液晶的基本知识。为以后液晶的高级应用打好基础。、本程序最终目的为:显示一个双行数字,并实现整屏移动。总的原理图及源程序如下:原理图:液晶电路图 液晶显示.ddb源程序:液晶例程液晶显示.c#include#define uchar unsigned char#define uint unsigned int uchar code table=I LIKE MCU!;uchar code table1=WWW.TXMCU.COM;sbit lcdwr=P25;/R
2、/S 命令选择端,H/L;sbit lcden=P27;/使能端sbit lcdrs=P26;/RS 数据/命令选择端。H/L;/sbit dula=P26;/sbit wela=P27;uchar num;void delay(uint z)/延时程序,z 的数是几就是几ms uint x,y;for(x=z;x0;x-)for(y=110;y0;y-);void write_com(uchar com)/写命令函数,lcdrs=0;/写入命令初始化,设置为低电平表示命令选择端。P0=com;/由时序图可知,在使能en 触发时,早就有数据写入。delay(5);/并且有一段延时,此处设置为5
3、 毫秒lcden=1;/使能端开始拉高delay(5);/由时序图,使能端拉低一段时间thD2后,数据传输?lcden=0;/然后将使能端拉低 void write_data(uchar date)lcdrs=1;P0=date;delay(5);/此处延时,是为了对应数据中:在E 拉高之前,有数据的一段准备时间。lcden=1;/由时序图可知:使能E 触发时,须有数据早就存在,故使能触发之后于数据的输入。delay(5);/充分时间,读取数据lcden=0;/数据读取完毕,将使能E 拉低,结束数据读取。void init()/初始化函数/dula=0;/将端选和位选设置为零,目的清零数码管,
4、不让其显示。/wela=0;/因为数码管的显示,消耗了电能,5V 电源供应不足。lcden=0;/状态字中允许标志可知:使能信号开始设置为0 才允许操作。write_com(0 x38);/根据数据,初始化设置显示模式为0 x38。write_com(0 x0e);/根据资料的初始化步骤:设置指令码:此处为光标显示不闪烁write_com(0 x06);/根据资料的初始化设置,读写一个字符时,指针加一,且游标加一。write_com(0 x01);/清屏指令,为了去除屏幕中出现的乱码影响显示效果。write_com(0 x80+0 x10);/数据指针设置。/*在整屏移动过程中,首先将数据放在
5、控制器中具体的位置在0 x10-0 x27中和 0 x-0 x57中*/void main()/主函数 lcdwr=0;/因为一直进行的是写操作,所以可以一直拉低,也可以设计电路接地。init();文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文
6、档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O
7、3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文
8、档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O
9、3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文
10、档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O
11、3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6for(num=0;num11;num+)/显示第一行 write_data(tablenum);delay(20);/每显示一个数用20ms /write_co
12、m(1);write_com(0 x80+0 x53);/换行显示for(num=0;num13;num+)write_data(table1num);delay(20);for(num=0;num16;num+)write_com(0 x18);/这是整屏移动指令,一共须移动十六个格delay(200);/用二百毫秒移动一次 while(1);/循环体,用于一直在屏幕上显示。显示效果:文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K
13、8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:
14、CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K
15、8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:
16、CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K
17、8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:
18、CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K
19、8L4 ZT8X9A3Y9L6现在将一步步的进行,逐步的完成程序的编写。首先进行的是单行显示:Helle,everyone!,不进行整屏移动。程序如下:#include#define uint unsigned int#define uchar unsigned char sbit lcdwr=P25;/读写选择端,H/L;sbit lcden=P27;/使能端sbit lcdrs=P26;/RS数据/命令选择端。H/L;uchar code table=Hello,everyone!;void write_com(uint com);/写入命令函数声明void write_dat(uchar
20、 dat);/写入数据函数声明void init();/初始化函数声明void delay(uint z)/在首个调用函数不用函数声明 uint x,y;for(x=z;x0;x-)for(y=110;y0;y-);/设置为 110,是用的 12M 晶振计算并测试得出结果为1ms void init()lcden=0;/不仅仅看时序图,注意读写允许操作时,使能端要为0 lcdwr=0;/因为一直进行写操作,所以,可以一直设置为0write_com(0 x01);/经试验,可以放在这里。write_com(0 x38);/有液晶数据,初始化步骤1write_com(0 x0f);/初始化步骤2,
21、选择为:开显示,显示光标并闪烁write_com(0 x06);/初始化步骤/write_com(0 x01);/清屏指令,如果不清屏,将会有别的乱码影响,可以考虑写在别的位置。write_com(0 x80+0);文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8
22、X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2
23、Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8
24、X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2
25、Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8
26、X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2
27、Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6void write_com(uint com)lcdrs=0;/因为一直写命令,所以可以设置为一直为0 P0=com;/由时序图可知,在使能e
28、n 触发时,早就有数据写入。delay(5);/并且有一段延时,此处设置为5 毫秒lcden=1;/使能端开始拉高delay(5);/由时序图,使能端拉低一段时间thD2后,数据传输完成lcden=0;/然后将使能端拉低 void write_dat(uchar dat)lcdrs=1;/因为在数据写入函数中,一直写的是数据,所以可以一直设置为1 P0=dat;/由时序图可知,在使能en 触发时,早就有数据写入。delay(5);/并且有一段延时,此处设置为5 毫秒lcden=1;/使能端开始拉高delay(5);/由时序图,使能端拉低一段时间thD2后,数据传输?lcden=0;/然后将使能
29、端拉低。void main()uint a;init();/定义一个初始化函数,个人习惯不在main函数中有太多的语句,大量运用函数调用for(a=0;a15;a+)write_dat(tablea);/调用数据写入函数delay(200);/每显示一个用50ms;while(1);/一直处于显示状态 显示效果如下:其效果为,每个字符逐个的出现。在屏幕上显示两行,不体现整屏移动 Hello,everyone!Welcome to 51!源程序如下:液晶例程液晶显示 1.c#include#define uint unsigned int#define uchar unsigned char s
30、bit lcdwr=P25;/读写选择端,H/L;sbit lcden=P27;/使能端sbit lcdrs=P26;/RS数据/命令选择端。H/L;uchar code table1=Hello,everyone!;uchar code table2=welcome to 51!;文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9
31、L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 H
32、T2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9
33、L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 H
34、T2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9
35、L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 H
36、T2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6void write_com(uint com);/写入命令函数声明void
37、 write_dat(uchar dat);/写入数据函数声明void init();/初始化函数声明void delay(uint z)/在首个调用函数不用函数声明 uint x,y;for(x=z;x0;x-)for(y=110;y0;y-);/设置为 110,是用的 12M 晶振计算并测试得出结果为1ms void init()lcden=0;/不仅仅看时序图,注意读写允许操作时,使能端要为0lcdwr=0;/因为一直进行写操作,所以,可以一直设置为0 write_com(0 x01);/经试验,可以放在这里。write_com(0 x38);/有液晶数据,初始化步骤1 write_co
38、m(0 x0f);/初始化步骤2,选择为:开显示,显示光标并闪烁write_com(0 x06);/初始化步骤/write_com(0 x01);/清屏指令,如果不清屏,将会有别的乱码影响,可以考虑写在别的位置。write_com(0 x80+0);void write_com(uint com)lcdrs=0;/因为一直写命令,所以可以设置为一直为0 P0=com;/由时序图可知,在使能en 触发时,早就有数据写入。delay(5);/并且有一段延时,此处设置为5 毫秒lcden=1;/使能端开始拉高delay(5);/由时序图,使能端拉低一段时间thD2后,数据传输完成lcden=0;/然
39、后将使能端拉低 void write_dat(uchar dat)lcdrs=1;/因为在数据写入函数中,一直写的是数据,所以可以一直设置为1 P0=dat;/由时序图可知,在使能en 触发时,早就有数据写入。delay(5);/并且有一段延时,此处设置为5 毫秒lcden=1;/使能端开始拉高delay(5);/由时序图,使能端拉低一段时间thD2后,数据传输?lcden=0;/然后将使能端拉低。void main()uint a,num;init();/定义一个初始化函数,个人习惯不在main函数中有太多的语句,大量运用函数调用文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT
40、8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H
41、2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT
42、8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H
43、2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT
44、8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H
45、2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT
46、8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6for(a=0;a15;a+)write_dat(table1a);/调用数据写入函数delay(200);/每显示一个用ms;write_com(0 x80+0 x42);/此处为换行指令,如果没有此指令将不会发生for(num=0;num14;num+)write_dat(table2num);delay(200);每显示一个字符用 while(1);/一直处于显示状态 显示效果如下:文档编码:CG8G8H2Q1K
47、7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A
48、3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K
49、7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A
50、3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K7 HT2O3P9K8L4 ZT8X9A3Y9L6文档编码:CG8G8H2Q1K