DS18B20中獲取溫度中tt=temp*0.0625;temp=tt*10+0.5;這兩句什么意思啊,為什么要有temp=tt*10+0.5??這時候tt不就是溫度啦嗎??這個求得是什么,能舉例子說明嗎?
uint tmp() //get the temperature
{
float tt;
uchar a,b;
dsreset();
delay(1);
tmpwritebyte(0xcc);
tmpwritebyte(0xbe);
a=tmpread();
b=tmpread();
temp=b;
temp<<=8; //two byte compose a int variable
temp=temp|a;
tt=temp*0.0625;
temp=tt*10+0.5;
return temp;
}
|