5b2954d54c6b64208a22b31dd9c7f8cd6e5841fd
[svn42.git] / rf433ctl / DallasTemperature / examples / Simple / Simple.pde
1 #include <OneWire.h>
2 #include <DallasTemperature.h>
3
4 // Data wire is plugged into port 2 on the Arduino
5 #define ONE_WIRE_BUS 2
6
7 // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
8 OneWire oneWire(ONE_WIRE_BUS);
9
10 // Pass our oneWire reference to Dallas Temperature. 
11 DallasTemperature sensors(&oneWire);
12
13 void setup(void)
14 {
15   // start serial port
16   Serial.begin(9600);
17   Serial.println("Dallas Temperature IC Control Library Demo");
18
19   // Start up the library
20   sensors.begin();
21 }
22
23 void loop(void)
24
25   // call sensors.requestTemperatures() to issue a global temperature 
26   // request to all devices on the bus
27   Serial.print("Requesting temperatures...");
28   sensors.requestTemperatures(); // Send the command to get temperatures
29   Serial.println("DONE");
30   
31   Serial.print("Temperature for the device 1 (index 0) is: ");
32   Serial.println(sensors.getTempCByIndex(0));  
33 }\r