#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar code table0[]="Welcome!";
uchar code table1[]="I Love You!";
uchar num;
sbit lcden=P2^2; //液晶使能端
sbit lcdrs=P2^0; //液晶数据命令选择端
//声明子函数
void delayms(uint xms); //延时函数
void write_com(uchar com); //液晶写命令函数
void write_data(uchar date); //液晶写数据函数
void led_init(); //液晶初始化函数
void t_init(); //定时器0初始化函数
void delayms(uint xms)//延时函数
{
uint i,j;
for(i=xms;i>0;i--)
for(j=110;j>0;j--); //11.0592MHZ
}
void write_com(uchar com)//液晶写命令函数
{
lcdrs=0;
P0=com;
delayms(5);
lcden=1;
delayms(5);
lcden=0;
}
void write_data(uchar date)//液晶写数据函数
{
lcdrs=1;
P0=date;
delayms(5);
lcden=1;
delayms(5);
lcden=0;
}
void led_init()//液晶初始化函数
{
lcden=0;
write_com(0x38); //设置16×2显示,5×7点阵,8位数据接口
write_com(0x0c); //设置开显示,不显示光标
write_com(0x06); //写一个字符后地址指针加1
write_com(0x01); //显示清0,数据指针清0
//write_com(0x80); //显示欢迎界面
}
void main()
{
led_init();
write_com(0x80);
for(num=0;num<11;num++)
{
write_date(table0[num]);
delayms(5);
}
write_com(0x80+0x40);
for(num=0;num<13;num++)
{
write_date(table1[num]);
delayms(5);
}
while(1);
}
Rebuild target 'Target 1'
assembling STARTUP.A51...
compiling 1602.c...
1602.c(61): warning C206: 'write_date': missing function-prototype
1602.c(61): error C267: 'write_date': requires ANSI-style prototype
Target not created.
Build Time Elapsed: 00:00:02
|