LCD12864液晶基本程序
时间:09-15
来源:互联网
点击:
#includereg52.h>
#includeintrins.h>
#define uchar unsingned char
#define uint unsigned int
sbit rs=P2^4;
sbit rw=P2^5;
sbit e=P2^6;
sbit psb=P2^7;
uchar table[]="20100419";
write_12864com(uchar com);
write_12864dat(uchar dat);
void initinal(void);
void display1(void);
void display2(void);
void display3(void);
void delay50us(uint t)//延时函数
{ uint j;
for(;t>0;t--)
for(j=6245;j>0;j--);
}
void main()
{
initnal();
while(1)
{
display1();
display2();
while(1);
}
}
write_12864com(uchar com) //写程序函数
{
rw=0;
rs=0; //表明写程序
delay_50us(1);
P0=com;
delay_50us(10);
E=0;
delay_50us(2);
}
write_12864dat(uchar dat) //写数据函数
{
rw=0;
rs=1;//表明写数据
delay_50us(1);
P0=dat;
delay_50us(10);
E=0;
delay_50us(2);
}
void initinal(void) //初始化函数
{ delay_50us(1);//等待100毫秒
write_2864com(0x30);
delay_50us(4);
write_2864com(0x30);
delay_50us(4);
write_2864com(0x0f);
delay_50us(4);
write_2864com(0x01);//清平显示
delay_50us(240);
write_2864com(0x06);
delay_50us(10);
}
void display1(void)//显示码
{ uchar a, i;
write_12864com(0x80); //写地址
delay_50us(1);
for(i=0;i16:i++)
{
write_12864dat(a); //写数据
delay_50us(1);
a++;
}
}
void display2(void)//显示汉字
{ uchar a,b,i;
write_12864com(0xBA); //写地址
write_12864com(0xC0);
delay_50us(1);
for(i=0;i16:i++)
{
write_12864dat(a);
write_12864dat(b); //写数据
delay_50us(1);
b++;
}
}
void display3(void)//更简单的显示函数
{ uchar i;
write_12864com(0x80); //写地址
for(i=0;i16:i++)
{
write_12864dat(table[i]);
delay_50us(1);
i++;
}
}
#includeintrins.h>
#define uchar unsingned char
#define uint unsigned int
sbit rs=P2^4;
sbit rw=P2^5;
sbit e=P2^6;
sbit psb=P2^7;
uchar table[]="20100419";
write_12864com(uchar com);
write_12864dat(uchar dat);
void initinal(void);
void display1(void);
void display2(void);
void display3(void);
void delay50us(uint t)//延时函数
{ uint j;
for(;t>0;t--)
for(j=6245;j>0;j--);
}
void main()
{
initnal();
while(1)
{
display1();
display2();
while(1);
}
}
write_12864com(uchar com) //写程序函数
{
rw=0;
rs=0; //表明写程序
delay_50us(1);
P0=com;
delay_50us(10);
E=0;
delay_50us(2);
}
write_12864dat(uchar dat) //写数据函数
{
rw=0;
rs=1;//表明写数据
delay_50us(1);
P0=dat;
delay_50us(10);
E=0;
delay_50us(2);
}
void initinal(void) //初始化函数
{ delay_50us(1);//等待100毫秒
write_2864com(0x30);
delay_50us(4);
write_2864com(0x30);
delay_50us(4);
write_2864com(0x0f);
delay_50us(4);
write_2864com(0x01);//清平显示
delay_50us(240);
write_2864com(0x06);
delay_50us(10);
}
void display1(void)//显示码
{ uchar a, i;
write_12864com(0x80); //写地址
delay_50us(1);
for(i=0;i16:i++)
{
write_12864dat(a); //写数据
delay_50us(1);
a++;
}
}
void display2(void)//显示汉字
{ uchar a,b,i;
write_12864com(0xBA); //写地址
write_12864com(0xC0);
delay_50us(1);
for(i=0;i16:i++)
{
write_12864dat(a);
write_12864dat(b); //写数据
delay_50us(1);
b++;
}
}
void display3(void)//更简单的显示函数
{ uchar i;
write_12864com(0x80); //写地址
for(i=0;i16:i++)
{
write_12864dat(table[i]);
delay_50us(1);
i++;
}
}
LCD12864液晶 基本程序 相关文章:
- PIC单片机驱动LCD12864液晶显示闪动字体程序(12-02)
- 51单片机+lcd12864液晶屏菜单程序(11-30)
- 单片机+lcd12864液晶万年历C程序(11-30)
- 51单片机控制LCD12864液晶屏显示图形菜单(11-30)
- LCD12864液晶显示的SHT11温湿度传感器程序(11-23)
- 基于51单片机运用LCD12864液晶显示(11-22)