请大侠门看看,写得不好,只显示已个数字,这个是我试验的程序,就是调试不出来,那些地方错误请大侠门指出来,我学习学习,刚学单片机,希望得到大侠门的帮助
问题:只显示一个数字,图片在后面,请大侠门分析分析
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit DQ=P3^7;
uchar code table[]={"0123456789"};
uchar rom[4][8]={0x28,0x30,0xc5,0xb8,0x00,0x00,0x00,0x8e,
0x28,0x31,0xc5,0xb8,0x00,0x00,0x00,0xb9,
0x28,0x32,0xc5,0xb8,0x00,0x00,0x00,0xe0,
0x28,0x33,0xc5,0xb8,0x00,0x00,0x00,0xd7,};
sbit rs=P2^0;
sbit rw=P2^1;
sbit lcden=P2^2;
uchar c;
void delay1602(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void write_com(uchar com)//写命令
{
rs=0;
lcden=0;
P0=com;
delay1602(5);
lcden=1;
delay1602(5);
lcden=0;
}
void write_date(uchar date)
{
rs=1;
lcden=0;
P0=date;
delay1602(5);
lcden=1;
delay1602(5);
lcden=0;
}
void init_lcd()
{
lcden=0;
rw=0;
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
write_com(0x80);
}
void delay_18b20(uchar count)
{
while(count--);
}
void init_18b20()
{
uchar x=0;
DQ=1;
delay_18b20(8);
DQ=0;
delay_18b20(80);
DQ=1;
delay_18b20(14);
x=DQ;
delay_18b20(20);
}
uchar read_18b20()
{
uchar i=0;
uchar date=0;
for (i=8;i>0;i--)
{
DQ=0;
date>>=1;
DQ=1;
if(DQ)
date=date|0x80;
delay_18b20(4);
}
return(date);
}
void write_18b20(uchar date)
{
uchar i;
for(i=8;i>0;i--)
{
DQ=0;
date=date&0x01;
delay_18b20(5);
DQ=1;
date>>=1;
}
}
void read_temp()
{
uchar temp,num,a,b,temp_value,shi,ge,xiaoshu;
uint value;
init_18b20();
delay1602(5);
write_18b20(0xcc);
write_18b20(0x44);
delay1602(5);
for(temp=4;temp>0;temp--)
{
init_18b20();
delay1602(5);
write_18b20(0x55);
for(num=8;num>0;num--)
write_18b20(rom[1][num]);
write_18b20(0xbe);
a=read_18b20();
b=read_18b20();
value=b;
value<<=8;
value=value|a;
temp_value=value*0.0625;
value=temp_value*10+0.5;
shi=value/100;
ge=value/10%10;
xiaoshu=value%10;
write_com(0x80);
write_date(table[shi]);
write_com(0x80+1+c);
write_date(table[ge]);
write_com(0x80+2+c);
write_date(table[xiaoshu]);
c=c+3;
delay1602(10);
}
c=0;
}
void main()
{
init_lcd();
while(1)
{
read_temp();
delay1602(10);
}
}