#include
#define uchar unsigned char
#define uint unsigned int
uchar code table[]'STC89C52RC'!;//这边错了
sbit lcden=P3^4;
sbit lcdrs=P3^5;
sbit dula=P2^6;
sbit wela=P2^7;
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;
P0=com;
delay(5);
lcday=1;
delay(5);
lcden=0;
}
viod write_data(uchar date)//这个write_data函数只能写一个字节
{
lcdrs=1;
P0=date;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void init()
{
dula=0;
wela=0;
lcden=0;
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
}
void main();
{
init();
write_com(0x80);
for(num=0;num<11;num++)
{
write_data(STC89C52RC);//write_data只能写一个字节,这边错了,还有如果要写单个字节,如果是字母的话,还得加引号
//如果要写一个字符串,可以另外写个函数
delay(5);
}
while(1)
}
你这个是什么意思啊,数学啊还是英文啊
基本看不懂,看看我的吧
//////1062/////////
void ydelay(uint x)
{
uint a,b;
for(a=x;a>0;a--)
for(b=10;b>0;b--);
}
void write_com(uchar com)
{
P0=com;
lcwr=0;
lcrs=0;
lcden=0;
ydelay(10);
lcden=1;
ydelay(10);
lcden=0;
lcwr=1;
}
void write_date(uchar date)//写数据
{
P0=date;
lcwr=0;
lcrs=1;
lcden=0;
ydelay(10);
lcden=1;
ydelay(10);
lcden=0;
lcwr=1;
}
void init1602()//初始化
{
write_com(0x38);//设置显示模式
ydelay(20);
write_com(0x0c);//开显示
ydelay(20);
write_com(0x06);//指针和光标自动加一
ydelay(20);
write_com(0x01);//清屏指令
ydelay(20);
}
void delay(uchar count) //delay
{
uint i;
while(count)
{
i=200;
while(i>0)
i--;
count--;
}
}
///////显示程序//////
void display(uchar bh,int num,int num1)
{
uchar a,A1,A2;
WDT_CONTR=0x34;
if(c!=0)
num=~num+1;
y=num1;
y=y&0x8000;
if(y!=0)
num1=~num1+1;
A1=num/1000;
A2=num1/1000;
if(nota!=1)
{
table1[0]=table[bh];
if(A1!=0)
table1[2]=table[A1];
else if(c!=0)
{
c=0;
table1[2]='-';
}
else
table1[2]=' ';
table1[3]=table[num%1000/100];
table1[4]=table[num%1000%100/10];
table1[6]=table[num%1000%100%10];
}
else
{
table1[0]=table[bh];
table1[2]='-';table1[3]='-';table1[4]='-';table1[6]='-';
}
if((not!=1)&&(not1!=1)&&(not2!=1))
{
if(A2!=0)
table2[2]=table[A2];
else if(y!=0)
{
y=0;
table2[2]='-';
}
else
table2[2]=' ';
table2[3]=table[num1%1000/100];
table2[4]=table[num1%1000%100/10];
table2[6]=table[num1%1000%100%10];
}
else
{table2[2]='-';table2[3]='-';table2[4]='-';table2[6]='-';}
write_com(0x80);
delay(2);
for(a=0;a<7;a++)
write_date(table1[a]);
delay(2);
write_com(0x89);
for(a=0;a<7;a++)
write_date(table2[a]);
delay(2);
write_com(0xc0);
for(a=0;a<16;a++)
write_date(table3[a]);
delay(2);
c=0;y=0;
}