1602液晶操作方法及代码
CODE:
#include
#define uint unsigned int
#define uchar unsigned char
sbit lcdwrite=P2^5;
sbit lcddatecommand=P2^6;
sbit lcde=P2^7;
uchar code LA_Mask[]="LA_Mask";
uchar code AT_Eagle[]="AT_Eagle";
uchar i;
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
{
for(y=0;y<=112;y++)
{
}
}
}
void write_command(uchar command)//写指令
{
lcddatecommand=0;
lcdwrite=0;
P0=command;
delay(1);
lcde=1;
delay(1);
lcde=0;
}
void write_date(uchar date)//写数据
{
lcddatecommand=1;
lcdwrite=0;
P0=date;
delay(5);
lcde=1;
delay(5);
lcde=0;
}
void init()
{
lcde=0;
write_command(0x38);//设置16*2显示,5*7点阵,8位数据接口
write_command(0x0c);//设置开显示,不显示光标
write_command(0x06);// 写一个字符后地址指针加1
write_command(0x01);//显示清0,数据指针清0
}
void main()
{
init();
write_command(0x80+0x10);
for(i=0;i<7;i++)
{
write_date(LA_Mask[i]);
delay(1);
}
write_command(0x80+0x50);
for(i=0;i<8;i++)
{
write_date(AT_Eagle[i]);
delay(1);
}
for(i=0;i<16;i++)
{
write_command(0x18);//整屏左移,同时光标跟随移动
//write_command(0x1c);//整屏右移,同时光标跟随移动
delay(200);
}
while(1);
}
1602液晶操作方法代 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)