Created
June 21, 2014 11:30
-
-
Save wendal/a1df2604497100c6842a to your computer and use it in GitHub Desktop.
arduino读取温度传感器数据,写入串口
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <OneWire.h> | |
#include "DallasTemperature.h" | |
OneWire oneWire(8); | |
DallasTemperature sensors(&oneWire); | |
void setup() { | |
Serial.begin(9600); | |
sensors.begin(); | |
} | |
void loop() { | |
//Serial.println("v=1"); | |
Serial.print("req temp1..."); | |
sensors.requestTemperatures(); | |
Serial.println("DONE"); | |
Serial.print("temp1="); | |
Serial.println(sensors.getTempCByIndex(0)); | |
delay(5000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment