1-Wire implementation, using DS2480B controller interfaced with serial port, working example to read DS18B20, based on work already in progress / Dallas - Public domain code

Dependencies:   mbed

Revision:
0:1193dbfe28e2
diff -r 000000000000 -r 1193dbfe28e2 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Mar 24 17:21:29 2011 +0000
@@ -0,0 +1,43 @@
+#include "mbed.h"
+#include "ds2480.h"
+#include "ownet.h"
+#include "readDS18B20.h"
+#include "findtype.h"
+
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+
+// defines
+#define MAXDEVICES         20
+// global serial numbers
+uchar FamilySN1[MAXDEVICES][8];
+
+int main() {
+
+    float temp = 0;
+    int NumDevices = 0;
+    
+    if ( DS2480Detect(3) ) {
+    
+        NumDevices = FindDevices(3, &FamilySN1[0], 0x10, MAXDEVICES);
+        
+        printf("dev: %d\r\n", NumDevices);
+        printf("sn:  ");
+        PrintSerialNum(FamilySN1[0]);
+        printf("\r\n");
+        led1 = 0;
+        while(1) {
+        
+            if (ReadDS18B20(3, FamilySN1[0],&temp)) {
+                printf("      %7.3f %cC\r\n", temp, 0xf8);
+            } else {
+                printf("     Error, reading temperature\r\n"); 
+            }
+    
+            led1 != led1;
+            wait(1);
+        }
+    } else {
+        printf("     Error, no DS2480 controller found\r\n");
+    }
+}
\ No newline at end of file