|
这是程序
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit LCDen=P2^2;
sbit LCDrs=P2^0;
sbit LCDrw=P2^1;
unsigned char code table[]="I LOVE MCx!";
unsigned char code table1[]="WWW.WZVCST.CN";
void delay(uint xms)
{
uint i,j;
for(i=xms;i>0;i--)
for(j=120;j>0;j--);
}
//R/W-->GND,no used
void write_com(uchar com)
{
LCDrw=0;
LCDrs=0;
P0=com;
delay(5);
LCDen=1;
delay(5);
LCDen=0;
}
void write_data(uchar date)
{
LCDrw=0
LCDrs=1;
P0=date;
delay(5);
LCDen=1;
delay(5);
LCDen=0;
}
void init()
{
write_com(0x38); //设置16*2显示,5*7点阵,8位数据接口
write_com(0x0c); //设置开显示,不显示光标
write_com(0x06); //写一个字符后地址指针加1
write_com(0x01); //显示清0,数据指针清0
}
void main()
{
unsigned char num;
init();
write_com(0x80); //the data start at 0x80. ref to table 7.2.4
for(num=0;num<11;num++)
{
write_data(table[num]);
delay(5);
}
//display the second row
write_com(0x80+0x40);
for(num=0;num<13;num++)
{
write_data(table1[num]);
delay(5);
}
while(1);
}
还有图
求大神帮忙
|
|