Skip to content

Instantly share code, notes, and snippets.

@wendal
Created June 21, 2014 11:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wendal/a1df2604497100c6842a to your computer and use it in GitHub Desktop.
Save wendal/a1df2604497100c6842a to your computer and use it in GitHub Desktop.
arduino读取温度传感器数据,写入串口
#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