ds18b20为什么能读出正确的温度?#include#define uchar unsigned char#define uint unsigned intsbit ds=P3^7;uchar code duan[]={//共阴数码管0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x40};uint temp;float f_temp;void delay(uint x){

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/06 03:48:01
ds18b20为什么能读出正确的温度?#include#define uchar unsigned char#define uint unsigned intsbit ds=P3^7;uchar code duan[]={//共阴数码管0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x40};uint temp;float f_temp;void delay(uint x){
xKO@OjؽTPoQp"i(Kh*A+"$xm_tkM U5RF;v6IEFǬݴ֌kɛNZpr?ݝ54O2U5@2N4CӀBڭK;R Y5iLARW)a`嬽q۳nc-elF≌DW}uXAb숿_im"$ξʻ K QҲ<}2 Joq}C-#9Vc6OaIȃX*[PUAJasN8!G9x{:r.,Ձ;#p~\̓_Ah(5P Hng_WRG')) vINp`b9"'㭭ˋpҞ;pj]xzԖc7nk6ȼ7;zTj_m gmz77`E jzҾކգvmۛuVʾmYq({l_jpX=[(EI{ D

ds18b20为什么能读出正确的温度?#include#define uchar unsigned char#define uint unsigned intsbit ds=P3^7;uchar code duan[]={//共阴数码管0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x40};uint temp;float f_temp;void delay(uint x){
ds18b20为什么能读出正确的温度?
#include
#define uchar unsigned char
#define uint unsigned int
sbit ds=P3^7;
uchar code duan[]={//共阴数码管
0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x40};
uint temp;
float f_temp;
void delay(uint x)
{
uint i,j;
for(i=x;i>0;i--)
for(j=110;j>0;j--);
}
void dsreset()
{
uint i;
ds=1;
i++;
ds=0;
i=30;
while(i--);
ds=1;
i=8;
while(i--);
if(ds)
{
i=4;
while(i--);
}
i=4;
while(i--);
}
uchar ReadDsbyte()//读一个字节
{
uint i;
uchar tmp=0,j;
for(j=8;j>0;j--)
{
ds=1;
i++;
ds=0;
tmp=tmp>>1;
ds=1;
if(ds)
tmp=tmp|0x80;
ds=1;
i=8;
while(i>0)
i--;
}
return tmp;
}
void WriteDsbyte(uchar y)//写一个字节
{
uchar j;
uint i;
for(j=1;j>1;
}
i=4;
while(i--);
}
void tempchange()//温度转换
{
dsreset();
delay(1);
WriteDsbyte(0xcc);
WriteDsbyte(0x44);
}
uint get_temp()//获取温度
{
uchar a,b;
dsreset();
delay(1);
WriteDsbyte(0xcc);
WriteDsbyte(0xbe);
a=ReadDsbyte();
b=ReadDsbyte();
temp=b;
temp=temp

ds18b20为什么能读出正确的温度?#include#define uchar unsigned char#define uint unsigned intsbit ds=P3^7;uchar code duan[]={//共阴数码管0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x40};uint temp;float f_temp;void delay(uint x){
蕊片内部本来就有温度转换器,给它一个信号它就会转换成二进制数存在内存空间中,你只需要按照人家的规定格式读出来就可以了.