LCD 1602液晶显示屏程序原代码如下:
/************************************/
/*程序:LCD 1602显示屏
/*日期: 2011-12-08
/*作者:guodiqing
/************************************/
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar code table[]="I LIKE MCU!";
uchar code table1[]="WWW.EEPW.COM.CN";
uchar code table2[]="welcome to";
uchar code table3[]="guodiqing MCUDIY";
sbit lcdrs=P2^4;
sbit lcdrw=P2^5;
sbit lcden=P2^6;
uchar num;
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void write_com(uchar com)
{
lcdrs=0;
lcdrw=0;
P0=com;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void write_data(uchar dat)
{
lcdrs=1;
lcdrw=0;
P0=dat;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void init()
{
delay(50);
lcden=0;
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
write_com(0x80);
}
void main()
{
init();
for(num=0;num<11;num++)
{
write_data(table[num]);
delay(200);
}
write_com(0x80+0x40);
for(num=0;num<15;num++)
{
write_data(table1[num]);
delay(200);
}
delay(10000);
init();
// delay(10000);
write_com(0x80+0x10);
for(num=0;num<10;num++)
{
write_data(table2[num]);
delay(200);
}
write_com(0x80+0x50);
for(num=0;num<16;num++)
{
write_data(table3[num]);
delay(200);
}
for(num=0;num<16;num++)
{
write_com(0x18);
delay(1000);
}
delay(10000);
}