LCD1602显示汉字“生日快乐”

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

1602显示“生日快乐”

////////////////////目标板:红油板/////////////////////

////////////////////修改自:不要显卡《1602显示汉字“生日快乐”》原因:乱码//////////////////////// #include

#define uchar unsigned char

#define uint unsigned int

sbit RS=P0^5;

sbit RW=P0^6;

sbit E=P0^7;

uchar sheng[]={0x04,0x14,0x1f,0x14,0x0e,0x04,0x1f,0x00}; //“生”字字模uchar ri[]={0x1f,0x11,0x11,0x1f,0x11,0x11,0x1f,0x00}; //“日”字字模

uchar kuai[]={0x0a,0x0a,0x1f,0x1b,0x1f,0x0a,0x0d,0x00}; //“快”字字模uchar le[]={0x1e,0x10,0x14,0x1f,0x04,0x15,0x15,0x00}; //“乐”字字模

void delay(uint m)

{

while(m--);

}

void Write_Instruction(uchar Instruction) //1602写命令

{

delay(5);

RS=0;

RW=0;

E=1;

P2=Instruction;

E=0;

}

void Write_Data(uchar Data) //1602写数据{

delay(5);

RS=1;

RW=0;

E=1;

P2=Data;

E=0;

}

void LCD1602_Init() //1602初始化

{

Write_Instruction(0x06);

Write_Instruction(0x30);

Write_Instruction(0x0c);

}

void main()

{

uchar i;

LCD1602_Init();

i=0;

while(1)

{

for(i=0;i<8;i++) //显示“生”

{

Write_Instruction(0x40+i);

Write_Data(sheng[i]);

delay(100);

}

Write_Instruction(0x86);

Write_Data(0x00);

for(i=0;i<8;i++) //显示“日”

{

Write_Instruction(0x48+i);

Write_Data(ri[i]);

delay(100);

}

Write_Instruction(0x87);

Write_Data(0x01);

for(i=0;i<8;i++) //显示“快”

{

Write_Instruction(0x50+i);

Write_Data(kuai[i]);

delay(100);

}

Write_Instruction(0x88);

Write_Data(0x02);

for(i=0;i<8;i++) //显示“乐”

{

Write_Instruction(0x58+i);

Write_Data(le[i]);

delay(100);

}

Write_Instruction(0x89);

Write_Data(0x03);

}

}

以上程序为静态显示,可修改显示“年”、“月”、“日”,也可修改字模达到显示任意简单汉字。

相关文档
最新文档