lcd1602能显示汉字吗_lcd1602显示汉字程序
============================================
void DisplayOneChar(unsigned char X, unsigned char Y, unsigned char DData)
{
Y &= 0x1;
X &= 0xF; //限制X不能大于15,Y不能大于1
if (Y) X |= 0x40; //当要显示第二行时地址码+0x40;
X |= 0x80; //算出指令码
WriteCommandLCM(X, 0); //这里不检测忙信号,发送地址码
WriteDataLCM(DData);
}
//=================================================================
//按指定位置显示一串字符
//void DisplayListChar(unsigned char X, unsigned char Y, unsigned char code *DData)
//说明: x(0-15):x参数 y(0-1):y参数 DData(字符串):要显示的内容(英文、数字、符号)
//========================================================================
void DisplayListChar(unsigned char X, unsigned char Y, unsigned char code *DData)
{
unsigned char ListLength,j; ListLength = strlen(DData);
Y &= 0x1;
X &= 0xF; //限制X不能大于15,Y不能大于1
if (X 《= 0xF) //X坐标应小于0xF
{
for(j=0;j《ListLength;j++)
{
DisplayOneChar(X, Y, DData[j]); //显示单个字符 X++;
}
}
}
//==========================================================
//显示自定义字符
//void mychar(char xx,char yy,unsigned char *character,unsigned char saveto)
//说明:xx(0-15):为x参数.yy(0-1):y参数.character:要显示的字符的列表地址,在程序前面有定义
//saveto(1-7)为字符保存的RAM,每屏最多显示7个自定义字符 //(0x00-0x0h是自定义字符)
//=============================================================
void mychar(char xx,char yy,unsigned char *character,unsigned char saveto)
{
unsigned char add = (saveto《《3) | 0x40;
unsigned char t; //临时变量,每一行的值 /*
t=*(character+0);
WriteCommandLCM(add, 0); //第1行 WriteDataLCM(t); t=*(character+1);
WriteCommandLCM(add+1, 0); //第2行 WriteDataLCM(t); t=*(character+2);
WriteCommandLCM(add+2, 0); //第3行 WriteDataLCM(t); t=*(character+3);
WriteCommandLCM(add+3, 0); //第4行 WriteDataLCM(t); t=*(character+4);
WriteCommandLCM(add+4, 0); //第5行 WriteDataLCM(t); t=*(character+5);
WriteCommandLCM(add+5, 0); //第6行 WriteDataLCM(t); t=*(character+6);
WriteCommandLCM(add+6, 0); //第7行 WriteDataLCM(t); t=*(character+7);
WriteCommandLCM(add+7, 0); //第8行 WriteDataLCM(t); */
for(i = 0;i《8;i++)
{
WriteCommandLCM(add+i, 0);
WriteDataLCM(*(character+i));
}
DisplayOneChar(xx,yy,saveto); //显示字符 }
//===============================================================
//主函数
//=========================================================
main()
{
Delay400Ms();
LCMInit();
Delay400Ms(); //1602初始化
while(1)
{
DisplayListChar(0,0,"This is ListChar"); DisplayListChar(0,1,"!");
for(j=0;j《30;j++)for(i=0;i《30000;i++); WriteCommandLCM(0x01,1); //清屏
Delay5Ms();
DisplayListChar(0,0,"This is OneChar:");
DisplayOneChar(0,1,0x4f);
DisplayOneChar(1,1,0x6e);
DisplayOneChar(2,1,0x65);
DisplayOneChar(3,1,0x21);
for(j=0;j《30;j++)for(i=0;i《30000;i++);
WriteCommandLCM(0x01,1); //清屏
Delay5Ms();
DisplayListChar(0,0,"This is MyChar:");
mychar(0,1, character0,1);
mychar(1,1, character1,2);
mychar(2,1, character2,3);
for(j=0;j《30;j++)for(i=0;i《30000;i++);
WriteCommandLCM(0x01,1); //清屏 Delay5Ms();
}
}
- LCD1602初始化流程图及程序的两种方法(09-08)
- 通用型LCD1602自定义字符的显示(02-12)
- 全方位解析LCD1602特性及单片机显示应用(09-17)
- LCD1602程序代码及显示流程图(09-12)
- 以LCD1602驱动程序为例分析C51单片机编程技巧(08-26)
- lcd1602工作原理是什么?(08-24)