额,如果你要用STC89C52单片机,你的代码第一行应该是
#include
The temperature data is stored as a 16-bit sign-extended
two’s complement number in the temperature register (see Figure 2). The sign bits (S) indicate if the
temperature is positive or negative: for positive numbers S = 0 and for negative numbers S = 1. If the
DS18B20 is configured for 12-bit resolution, all bits in the temperature register will contain valid data.
For 11-bit resolution, bit 0 is undefined. For 10-bit resolution, bits 1 and 0 are undefined, and for 9-bit
resolution bits 2, 1, and 0 are undefined. Table 1 gives examples of digital output data and the
corresponding temperature reading for 12-bit resolution conversions.
温度信息存放于16位扩展寄存器中,符号(S)表示温度的正负,温度为正数S = 0,温度为负数S=1。
当ds18B20配置12位精度时寄存器所有值有效,
当11位精度 时寄存器0位不用
当10位精度 时寄存器0,1位不用
当10位精度 时寄存器0,1,2位不用
表一给出温度与传感器输出值的对照
翻译的不好的地方请指正
我有做过这个,你把邮箱留下,我发给你。程序加PROTEUS的图