#include
#define uint unsigned int
#define uchar unsigned char
sbit rs=P2^0;
sbit rw=P2^1;
sbit lcden=P2^2;
sbit busy=P0^7;
uchar flag,fuhao,temp,num,i,j;
long a,b,c;
uchar code table[]={
7,4,1,0,
8,5,2,0,
9,6,3,0,
0,0,0,0};
uchar code table0[]={
7,4,1,0x01-0x30,
8,5,2,0,
9,6,3,0x3d-0x30,
0x2f-0x30,0x2a-0x30,0x2d-0x30,0x2b-0x30
}; //由于液晶显示字符的形式有一定的区别,都要在符号表上寻找一个数值的形式
void init();
void write_com(uchar com);
void write_dat(uchar dat);
void keyscan();
void delay(uchar z) // 延迟函数
{
uchar y;
for(z;z>0;z--)
for(y=0;y<110;y++);
}
void check(); // 判断忙或空闲
void main()
{
init();
while(1)
{keyscan();
}
}
void check()
{
do{
P0=0xFF;
rs=0; //指令
rw=1; //读
lcden=0; //禁止读写
delay(1); //等待,液晶显示器处理数据
lcden=1; //允许读写
}while(busy==1); //判断是否为空闲,1为忙,0为空闲
}
void write_com(uchar com)
{ P0=com;
rs=0;
rw=0;
lcden=0;
check();
lcden