编辑: 山南水北 2016-07-07

return;

} if ( addr[0] == 0x10) { Serial.print("Device is a DS18S20 family device.\n");

} else if ( addr[0] == 0x28) { Serial.print("Device is a DS18B20 family device.\n");

http://keyes-arduino.taobao.com http://keyes-arduino.taobao.com } else { Serial.print("Device family is not recognized: 0x");

Serial.println(addr[0],HEX);

return;

} ds.reset();

ds.select(addr);

ds.write(0x44,1);

// start conversion, with parasite power on at the end delay(1000);

// maybe 750ms is enough, maybe not // we might do a ds.depower() here, but the reset will take care of it. present = ds.reset();

ds.select(addr);

ds.write(0xBE);

// Read Scratchpad Serial.print("P=");

Serial.print(present,HEX);

Serial.print(" ");

for ( i = 0;

i < 9;

i+we need

9 bytes data[i] = ds.read();

Serial.print(data[i], HEX);

Serial.print(" ");

} Serial.print(" CRC=");

Serial.print( OneWire::crc8( data, 8), HEX);

Serial.println();

}

七、结束语 这节到这里就要告一段落了,相信看完这节介绍后对 DS18B20 已不再是那么畏惧了 吧,其实只要我们掌握了,就能随心所欲的使用它并设计我们个性化的电子产品,自己 也动手试试吧..... 我们还有很多相关的电子产品,敬请关注! http://keyes-arduino.taobao.com http://keyes-arduino.taobao.com http://keyes-arduino.taobao.com http://keyes-arduino.taobao.com

下载(注:源文件不在本站服务器,都将跳转到源网站下载)
备用下载
发帖评论
相关话题
发布一个新话题