本站改版新增arduino频道
arduino DS18B20温度传感器
#include <OneWire.h> #include <DallasTemperature.h> #define ONE_WIRE_BUS 2 OneWire oneWire(ONE_WIRE_BUS); DallasTemperature sensors(&oneWire); void setup() { Serial.begin(9600); sensors.begin(); } void loop() { sensors.requestTemperatures(); float temperature = sensors.getTempCByIndex(0); Serial.print("Temperature: "); Serial.print(temperature); Serial.println(" °C"); delay(1000); }
Copyright © 2014 ESP56.com All Rights Reserved
晋ICP备14006235号-22 晋公网安备14108102001165号
执行时间: 0.0096199512481689 seconds