******voidWriteOneByte(uchardat){uchari;for(i=8;i>0;i--){DQ=0;DQ=dat&0x01;delay_DS18B20(10);DQ=1;dat>>=1;}}//************DS18B20读取温度值并转换******************Read_Temperature(){uchara,b;Init_DS18B20();WriteOneByte();//跳过读序列号WriteOneByte(0x44);//启动温度转换Init_DS18B20();WriteOneByte();//跳过读序列号WriteOneByte(0xbe);//读取温度a=ReadOneByte();b=ReadOneByte();tvalue=b;tvalue<<=8;tvalue=tvalue|a;if(tvalue<0xfff)tflag=0;else{tvalue=~tvalue+1;tflag=1;}tvalue=tvalue*(0.625);//温度值扩大10倍,精确到1位小数...return(tvalue);}//************DS18B20温度显示******************voidDS18B20_display(){ucharflagdat;disdata[0]=tvalue/1000+0x30;//百位数disdata[1]=tvalue_x0010_00/100+0x30;//十位数disdata[2]=tvalue_x0010_0/10+0x30;//个位数disdata[3]=tvalue_x0010_+0x30;//小数位if(tflag==0)flagdat=0x20;//正温度不显示符号elseflagdat=0x2d;//负温度显示负号if(disdata[0]==0x30){