LCD12864 液晶屏带中文字库
我们的液晶模块在出厂前都经过的测试,质量有保证!
lcd12864接口定义如下:
并口模式如下:
第1脚:vss为地电源
第2脚:vdd接5v正电源
第3脚:v0为液晶显示器对比度调整端,接正电源时对比度Zui弱,接地电源时对比度Zui高
第4脚:rs为寄存器选择,高电平时选择数据寄存器、低电平时选择指令寄存器。
第5脚:r/w 当r/w和e都为高电平时,数据被读到db0~db7;当r/w为低电平,e从高电平变为低电平,db0~db7的数据被写到ir或dr寄存器。
第6脚:e 使能信号
第7~14脚:db0~db7 为8位双向数据线。
第15脚:psb 并行/串行选择。当psb为高电平时是并行模式;当psb为低电平时,是串行模式。
第16脚:nc 空脚。
第17脚:/reset 复位脚。低电平有郊。
第19脚:a 背光灯电源正极,接+5v。
第20脚:k 背光灯电源负极,接地。
串口模式如下:
第1脚:vss为地电源
第2脚:vdd接5v正电源
第3脚:v0为液晶显示器对比度调整端,接正电源时对比度Zui弱,接地电源时对比度Zui高
第4脚:cs 片选信号,高电平有效。
第5脚:sid 串行数据输入端。
第6脚:clk 串行同步时钟。
第17脚:/reset 复位脚。低电平有郊。
第19脚:a 背光灯电源正极,接+5v。
第20脚:k 背光灯电源负极,接地。
参考的51单片机程序如下:
请注意电路的接口不同,程序需要相应地修改。
#include <reg51.h>
#include <intrins.h>
//#include <at89x51.h>
sbit lcd_rs=p1^0;//定义引脚
sbit lcd_rw=p1^1;
sbit lcd_e=p1^2;
sbit psb =p3^6; //psb脚为12864-12系列的串、并通讯功能切换,我们使用8位并行接口,psb=1
#define lcd_data p2
#define busy 0x80 //用于检测lcd状态字中的busy标识
void writedatalcd(unsigned char wdlcd);
void writecommandlcd(unsigned char wclcd,buysc);
unsigned char readdatalcd(void);
unsigned char readstatuslcd(void);
void lcdinit(void);
void lcdclear(void);
void lcdflash(void);
void displayonechar(unsigned char x, unsigned char y, unsigned char ddata);
void displaylistchar(unsigned char x, unsigned char y, unsigned char code *ddata);
void displayimage (unsigned char code *ddata);
void delay5ms(void);
void delay400ms(void);
code unsigned char uctech[] = {"丰利电子营业部"};
code unsigned char net[] = {"http://gzfnjd.1688.com/"};
code unsigned char mcu[] = {"专业元件供应商!"};
code unsigned char qq[] = {" qq: 805041779 "};
code unsigned char tmp[]={//128*64点阵图形数据
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x5f,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xff,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0xff,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0xe1,0xff,0xe0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x0f,0xf9,0xff,0xef,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x1f,0xfd,0xff,0xff,0xf8,0x00,0x00,0x18,0x00,0x87,0x00,0x18,0x00,0x00,0xc0,
0x00,0x1f,0xfe,0xff,0xff,0xf8,0x00,0x00,0x18,0x01,0x8d,0x80,0x18,0x01,0xf7,0xc0,
0x00,0x3f,0xff,0xff,0xff,0xfc,0x00,0x00,0x18,0x01,0x8d,0xa0,0x18,0x00,0x03,0x80,
0x00,0x3f,0xff,0xff,0xff,0xfc,0x00,0x00,0x18,0x27,0xff,0xf1,0xff,0xc0,0x06,0x00,
0x00,0x3f,0xff,0xff,0xff,0xfc,0x00,0x03,0xff,0xf1,0x9d,0x01,0x08,0xc0,0x0c,0x00,
0x00,0x3f,0xff,0xff,0xff,0xfc,0x00,0x00,0x18,0x01,0x7d,0x61,0x18,0xc0,0x08,0x60,
0x00,0x1f,0xff,0xff,0xff,0xfc,0x00,0x00,0x18,0x01,0xdf,0xe1,0xff,0xc7,0xff,0xf0,
0x00,0x1f,0xff,0xff,0xff,0xfc,0x00,0x00,0x1c,0x03,0xed,0x01,0x18,0xc0,0x08,0x00,
0x00,0x1f,0xff,0x01,0xff,0xf8,0x00,0x00,0x16,0x02,0x8d,0x61,0x18,0xc0,0x08,0x00,
0x00,0x0f,0xfe,0x00,0xff,0xf8,0x00,0x00,0x32,0x02,0xad,0x81,0xff,0xc0,0x08,0x00,
0x00,0x07,0xf8,0x00,0x3f,0xd0,0x00,0x00,0x23,0x07,0x3d,0x01,0x18,0x20,0x08,0x00,
0x00,0xfd,0xf8,0x00,0x3f,0xe0,0x00,0x00,0x61,0x85,0xfd,0x20,0x18,0x20,0x08,0x00,
0x01,0xff,0xf0,0x00,0x1f,0x40,0x00,0x00,0x80,0xf0,0x0f,0xe0,0x18,0x20,0x78,0x00,
0x03,0xff,0xf0,0x00,0x0f,0x80,0x00,0x03,0x00,0x60,0x0c,0x00,0x0f,0xe0,0x18,0x00,
0x03,0xff,0xe0,0x00,0x0f,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x07,0xff,0xe0,0x00,0x0f,0xf4,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x07,0xff,0xe0,0x00,0x0f,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x07,0xff,0xe0,0x00,0x0f,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x03,0xff,0xe0,0x00,0x0f,0xff,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x03,0xff,0xe0,0x00,0x1f,0xff,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x03,0xff,0xf0,0x00,0x1f,0xff,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0xff,0xf0,0x00,0x3f,0xff,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0xff,0xf8,0x00,0x7f,0xff,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0xff,0xfc,0x00,0xff,0xff,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x3f,0xff,0x87,0xff,0xff,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x03,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x03,0xff,0xff,0xff,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x03,0xff,0xff,0xff,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x03,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x03,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x03,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x03,0xff,0xff,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x03,0xff,0xff,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x03,0xff,0xff,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0xff,0xff,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xfe,0x77,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x70,0x01,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x70,0x0f,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x70,0x3f,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x78,0xff,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x1f,0xfc,0x79,0xff,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x7f,0xff,0x39,0xff,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0xff,0xff,0xfd,0xff,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0xff,0xff,0xff,0xff,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0xff,0xff,0xff,0xff,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x7f,0xff,0xfe,0xff,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x3f,0xff,0xef,0x7e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x0f,0xff,0xef,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x07,0xff,0xc7,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0xff,0x83,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x1e,0x01,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};
void main(void)
{
delay400ms(); //启动等待,等lcd讲入工作状态
lcdinit(); //lcm初始化
delay5ms(); //延时片刻(可不要)
while(1){
lcdclear();
displayimage(tmp);//显示图形
delay400ms();
delay400ms();
delay400ms();
delay400ms();
delay400ms();
lcdclear();
displaylistchar(0,1,uctech); //显示字库中的中文数字
displaylistchar(0,2,net); //显示字库中的中文数字
displaylistchar(0,3,mcu); //显示字库中的中文
displaylistchar(0,4,qq); //显示字库中的中文数字
delay400ms();
delay400ms();
delay400ms();
delay400ms();
lcdflash(); //闪烁效果
//}
}
}
//写数据
void writedatalcd(unsigned char wdlcd)
{
readstatuslcd(); //检测忙
lcd_rs = 1;
lcd_rw = 0;
lcd_data = wdlcd;
lcd_e = 1;
lcd_e = 1;
lcd_e = 1;
lcd_e = 0;
}
//写指令
void writecommandlcd(unsigned char wclcd,buysc) //buysc为0时忽略忙检测
{
if (buysc) readstatuslcd(); //根据需要检测忙
lcd_rs = 0;
lcd_rw = 0;
lcd_data = wclcd;
lcd_e = 1;
lcd_e = 1;
lcd_e = 1;
lcd_e = 0;
}
//读数据
unsigned char readdatalcd(void)
{
lcd_rs = 1;
lcd_rw = 1;
lcd_e = 0;
lcd_e = 0;
lcd_e = 1;
return(lcd_data);
}
//读状态
unsigned char readstatuslcd(void)
{
lcd_data = 0xff;
lcd_rs = 0;
lcd_rw = 1;
lcd_e = 1;
while (lcd_data & busy); //检测忙信号
lcd_e = 0;
return(lcd_data);
}
void lcdinit(void) //lcm初始化
{
writecommandlcd(0x30,1); //显示模式设置,开始要求每次检测忙信号
writecommandlcd(0x01,1); //显示清屏
writecommandlcd(0x06,1); // 显示光标移动设置
writecommandlcd(0x0c,1); // 显示开及光标设置
}
void lcdclear(void) //清屏
{
writecommandlcd(0x01,1); //显示清屏
writecommandlcd(0x34,1); // 显示光标移动设置
writecommandlcd(0x30,1); // 显示开及光标设置
}
void lcdflash(void) //闪烁效果
{
writecommandlcd(0x08,1); //显示清屏
delay400ms();
writecommandlcd(0x0c,1); // 显示开及光标设置
delay400ms();
writecommandlcd(0x08,1); //显示清屏
delay400ms();
writecommandlcd(0x0c,1); // 显示开及光标设置
delay400ms();
writecommandlcd(0x08,1); //显示清屏
delay400ms();
}
//按指定位置显示一个字符
void displayonechar(unsigned char x, unsigned char y, unsigned char ddata)
{
if(y<1)
y=1;
if(y>4)
y=4;
x &= 0x0f; //限制x不能大于16,y不能大于1
switch(y){
case 1:x|=0x80;break;
case 2:x|=0x90;break;
case 3:x|=0x88;break;
case 4:x|=0x98;break;
}
writecommandlcd(x, 0); //这里不检测忙信号,发送地址码
writedatalcd(ddata);
}
//按指定位置显示一串字符
void displaylistchar(unsigned char x, unsigned char y, unsigned char code *ddata)
{
unsigned char listlength,x2;
listlength = 0;
x2=x;
if(y<1)
y=1;
if(y>4)
y=4;
x &= 0x0f; //限制x不能大于16,y在1-4之内
switch(y){
case 1:x2|=0x80;break; //根据行数来选择相应地址
case 2:x2|=0x90;break;
case 3:x2|=0x88;break;
case 4:x2|=0x98;break;
}
writecommandlcd(x2, 1); //发送地址码
while (ddata[listlength]>=0x20) //若到达字串尾则退出
{
if (x <= 0x0f) //x坐标应小于0xf
{
writedatalcd(ddata[listlength]); //
listlength++;
x++;
delay5ms();
}
}
}
//图形显示122*32
void displayimage (unsigned char code *ddata){
unsigned char x,y,i;
unsigned int tmp=0;
for(i=0;i<9;){ //分两屏,上半屏和下半屏,因为起始地址不同,需要分开
for(x=0;x<32;x++){ //32行
writecommandlcd(0x34,1);
writecommandlcd((0x80+x),1);//列地址
writecommandlcd((0x80+i),1); //行地址,下半屏,即第三行地址0x88
writecommandlcd(0x30,1);
for(y=0;y<16;y++)
writedatalcd(ddata[tmp+y]);//读取数据写入lcd
tmp+=16;
}
i+=8;
}
writecommandlcd(0x36,1); //扩充功能设定
writecommandlcd(0x30,1);
}
//5ms延时
void delay5ms(void)
{
unsigned int tempcyc = 5552;
while(tempcyc--);
}
//400ms延时
void delay400ms(void)
{
unsigned char tempcyca = 5;
unsigned int tempcycb;
while(tempcyca--)
{
tempcycb=7269;
while(tempcycb--);
};
}
本产品的加工定制是是,品牌是自主品牌,型号是12864【带中文字库】,种类是LCM液晶模块,屏幕尺寸是3(英寸),色彩是单色
联系方式
- 地址:广东广州市越秀区惠福西路175号 公司地址 广州前进路南园大..
- 邮编:510500
- 电话:86-02081881408
- 经理:宁利云
- 手机:18688397397
- 传真:86 020 83367769