您的位置 首页 汽车

LCD1602液晶屏幕显现介绍

下面是protues仿真电路,屏幕中第二行能看清吧,后面再说怎么显示的,第一行是我自定义的汉字确认和取消的取(左右写反了),发现1602显示…

下面是protues仿真电路,屏幕中第二行能看清吧,后边再说怎样显现的,榜首行是我自界说的汉字“承认”和“撤销”的“取”(左右写反了),发现1602显现汉字也就自己弄着玩玩,派不上大场合,并且假如一个汉字占两个字符的话(就像下图显现的),最多只能自界说4个汉字。

先贴上程序,后边再剖析。

#include
#include

#define uchar unsigned char
#define uint unsigned int

uchar code line1[] = {“welcome!”};

uchar p[]= //自界说字模数组
{
0x00,0x0f,0x04,0x0f,0x05,0x07,0x00,0x00,
0x0f,0x12,0x1f,0x15,0x1f,0x15,0x1f,0x15, //确
0x04,0x02,0x0e,0x02,0x02,0x03,0x02,0x00,
0x04,0x04,0x04,0x04,0x04,0x0a,0x11,0x00, //认
0x00,0x0f,0x09,0x06,0x06,0x06,0x09,0x00,
0x1f,0x0a,0x0e,0x0e,0x0a,0x1f,0x02,0x02 //取
};

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

busying ()
{
bit result;
RS = 0;
RW = 1;
E = 1;
_nop_();
_nop_();
_nop_();
_nop_();
result = (bit)(P0&0x80);
E = 0;
return result;
}

writeorder (uchar cmd)
{
while (busying());
RS = 0;
RW = 0;
E = 0;
_nop_();
_nop_();
P0 = cmd;
_nop_();
_nop_();
_nop_();
_nop_();
E = 1;
_nop_();
_nop_();
_nop_();
_nop_();
E = 0;
}

writedata (uchar dat)
{
while (busying());
RS = 1;
RW = 0;
E = 0;
_nop_();
_nop_();
P0 = dat;
_nop_();
_nop_();
_nop_();
_nop_();
E = 1;
_nop_();
_nop_();
_nop_();
_nop_();
E = 0;
}

delay(uchar i)
{
while(i–)
{
uchar j=250;
while(j–)
{
_nop_();
_nop_();
_nop_();
_nop_();
}
}
}

initial ()
{
delay (150);
writeorder (0x38);//工作方法:8位、2行、5×7
delay(5);
writeorder (0x06); //输入方法:光标右移、屏幕不动
delay(5);
writeorder (0x0c);//显现状况:显现开、有光标、不闪耀
delay(5);
writeorder (0x01);//清屏
delay(5);
}

newbyte (void) //设置自界说字符
{
uchar i,j,k=0;
uchar temp=0x40;
for(j=0;j<6;j++)
{
for(i=0;i<8;i++)
{
writeorder(temp+i);
writedata(p[k]);
k++;
}
temp += 8;
}
}

main (void)
{
uchar i=0;
initial ();
newbyte ();
writeorder (0x85); //设置榜首行显现方位
writedata (0x00);
writedata (0x01);
writedata (0x02);
writedata (0x03);
writedata (0x04);
writedata (0x05);

writeorder (0xc4); //设置第二行显现方位
while(line1[i] != \0)
{ // 显现字符”welcome!”
writedata(line1[i]);
i++;
}
while (1);
}

假如之前没有触摸过1602,这里有材料,可避免注册免费下载:

http://wdpvip.qupan.com/6311643.html

http://wdpvip.qupan.com/6311649.html

下载:LCD1602汉字显现解说.doc

程序中函数名界说的都很清楚了,不清楚的后边都有注释,弥补两点:

1、数组uchar p[]和函数newbyte ()是为了自界说汉字的,能够删除去。

2、1602共有两行,榜首行显现从0x80开端,第二行从0xc0开端

举例说明,想在榜首行第二个光标处显现,地址便是:0x81;想在第二行第三个光标处显现,地址便是:0xc2.

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/qiche/274791.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部