DS18B20测温程序#include#includeunsigned char code tab1[ ]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};//不带小数点unsigned char code tab2[ ]={0xbf,0x86,0xdb,0xcf,0xe6,0xed,0xfd,0x87,0xff,0xef };//带小数点sbit TMDAT=P0^0;sbit ds=P
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/26 21:44:04
DS18B20测温程序#include#includeunsigned char code tab1[ ]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};//不带小数点unsigned char code tab2[ ]={0xbf,0x86,0xdb,0xcf,0xe6,0xed,0xfd,0x87,0xff,0xef };//带小数点sbit TMDAT=P0^0;sbit ds=P
DS18B20测温程序
#include
#include
unsigned char code tab1[ ]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};//不带小数点
unsigned char code tab2[ ]={0xbf,0x86,0xdb,0xcf,0xe6,0xed,0xfd,0x87,0xff,0xef };//带小数点
sbit TMDAT=P0^0;
sbit ds=P2^2;//数据输入
sbit dula=P2^6;
sbit wela=P2^7;
unsigned int sdata;//测量到的温度整数部分
unsigned char xiaoshu1; // 小数第一位
unsigned int temp;//温度
unsigned char flag;//检测DS18B320是否存在标志位
void delay(int m,int n,int l)//延时子程序
{
int x,y,z;
for ( x=0;x
DS18B20测温程序#include#includeunsigned char code tab1[ ]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};//不带小数点unsigned char code tab2[ ]={0xbf,0x86,0xdb,0xcf,0xe6,0xed,0xfd,0x87,0xff,0xef };//带小数点sbit TMDAT=P0^0;sbit ds=P
895.9,说明温度传感器还没有完成转换,你就读它了,注意时序,最后要有750ms的延时你好像没写