LCD12864点阵型液晶简介:
12864是一种图形点阵液晶显示器,它主要由行驱动器/列驱动器及128×64全点阵液晶显示器组成。可完成图形显示,也可以显示8×4个(16×16点阵)汉字。
LCD12864 引脚介绍:
LCD12864液晶屏幕原理图:LCD12864液晶屏幕驱动程序:
//12864液晶操作口
sbit rs = P1^0; sbit rw = P1^1;
sbit en = P1^2;
/*******12864驱动程序************/
//===========液晶写指令==========
void writecommand(uchar command) { checkbusy(); rs=0; rw=0; en=1; P0=command; //液晶数据线P0 en=0; } //============液晶写数据========================================= void writedata(uchar date) { checkbusy(); rs=1; rw=0; en=1; P0=date; en=0; } //==============液晶设置========================================= void lcdset(void) { writecommand(0x30); //基本指令集 writecommand(0x01); //清屏,DDRAM的地址归零 writecommand(0x02); //地址归位 writecommand(0x0c); //显示开,光标关,反白关 writecommand(0x06); //DDRAM地址加1 } //===========设置光标============================================= void cursor(uchar y,uchar x) { uchar command = 0x80; writecommand(0x0f); //开光标 闪烁 if( y == 2) y = 3; else if(y == 3) y = 2; command |= (y-1) << 3; command += (x-1); writecommand(command); } //===========字符显示============================================ void display(uchar y, uchar x, uchar *p) { switch (y) { case 1:writecommand(0x7f+x); break; //液晶第一行 case 2:writecommand(0x8f+x); break; //0x90+(x-1) case 3:writecommand(0x87+x);break; case 4:writecommand(0x97+x);break; default:break; } while(*p) writedata(*p++); } //=========显示数字=============================================== void displayNumber(uchar y,uchar x,uchar number) { switch (number) { //引号内数字为中文全角输入 占据一个汉字位置 case 0:display(y,x,"0");break; case 1:display(y,x,"1");break; case 2:display(y,x,"2");break; case 3:display(y,x,"3");break; case 4:display(y,x,"4");break; case 5:display(y,x,"5");break; case 6:display(y,x,"6");break; case 7:display(y,x,"7");break; case 8:display(y,x,"8");break; case 9:display(y,x,"9");break; default:break; }}
void displaytime0(void) //静态数据
{
display(1, 2, "智能作息系统");
display(2, 3, "年");
display(2, 6, "月");
display(3, 1, "星期");
display(3, 8, "℃");
display(4, 3, "-"); //全角输入
display(4, 6, "-");
}
/*******12864主程序调用************/
lcdset();
delay(1000);
lcdset(); //调用两次可以解决上电后液晶不能自动复位问题
/*显示版本信息*/
display(1,3,"welcome!");
display(2,2,"智能作息系统");
display(3,3,"版本1.0");
display(4,1,"制作人: 马云");
writecommand(0x01); //清屏 LCD12864液晶屏幕显示效果: |