Auto search for All DS18B20 sensors on data bus

Dependencies:   mbed

Revision:
0:a2a81f538133
diff -r 000000000000 -r a2a81f538133 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Apr 13 10:06:52 2014 +0000
@@ -0,0 +1,33 @@
+#include <mbed.h>
+#include "DS18B20.h"
+#include "OneWireDefs.h"
+
+#define THERMOMETER DS18B20
+
+float temp;
+// device( mbed pin )
+THERMOMETER device(PTC11);
+
+void readTemp(int deviceNum)
+{
+    temp = device.readTemperature(deviceNum);
+    printf("Device %d is %f\n\r",deviceNum, temp);
+    wait(0.5);
+}
+
+int main()
+{
+    
+    while (!device.initialize());    // keep calling until it works
+
+    int deviceCount = device.getDeviceCount();
+    printf("Found %d sensors\n\r",deviceCount);
+
+    device.setResolution(twelveBit);
+    while (true)
+    {
+        for (int i = 0;i < deviceCount; i++)
+            readTemp(i);
+    }
+}
+