谢谢各位,我昨天看资料写的程序
uint16_get_temp()
{
uint8 a,b;
uint16 d;
float c;
temp_change();
INIT_DS18B20();
delay(1);
DS18B20_write(0xcc);
DS18B20_write(0xbe);
a=DS18B20_read();
b=DS18B20_read();
d=b;
d<<=8;
d=d|a;
c=d*0.0625;
temp1=c*10+0.5;
return temp1;
}
奇怪的是,读出来的显示在1602的数,大了好多。不知是何故???
void main()
{
LCD_init();
while(1)
{
temp2=uint16_get_temp();
delay_us(20);
shi=temp2/10;
ge=temp2%10;
LCD_write_com(0x80);
LCD_write_date(0x30+shi);
LCD_write_date(0x30+ge);
LCD_write_date('.');
}
}
谢谢各位,我昨天看资料写的程序
uint16_get_temp()
{
uint8 a,b;
uint16 d;
float c;
temp_change();
INIT_DS18B20();
delay(1);
DS18B20_write(0xcc);
DS18B20_write(0xbe);
a=DS18B20_read();
b=DS18B20_read();
d=b;
d<<=8;
d=d|a;
c=d*0.0625;
temp1=c*10+0.5;
return temp1;
}
奇怪的是,读出来的显示在1602的数,大了好多。不知是何故???
void main()
{
LCD_init();
while(1)
{
temp2=uint16_get_temp();
delay_us(20);
shi=temp2/10;
ge=temp2%10;
LCD_write_com(0x80);
LCD_write_date(0x30+shi);
LCD_write_date(0x30+ge);
LCD_write_date('.');
}
}
举报