testing DS1820

Dependencies:   DS1820 mbed-dev

Fork of DS1820_HelloWorld by Erik -

Files at this revision

API Documentation at this revision

Comitter:
zappo
Date:
Tue Aug 01 10:47:48 2017 +0000
Parent:
4:01060b5e01b4
Commit message:
test1

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-dev.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show diff for this revision Revisions of this file
diff -r 01060b5e01b4 -r 7cc3a5fc200d main.cpp
--- a/main.cpp	Fri Jan 13 18:30:37 2017 +0000
+++ b/main.cpp	Tue Aug 01 10:47:48 2017 +0000
@@ -1,5 +1,5 @@
 #define MULTIPLE_PROBES
-#define DATA_PIN        A0
+#define DATA_PIN        A0   // A0 = P0_23
 
 
 #ifdef MULTIPLE_PROBES
@@ -10,8 +10,13 @@
 #define MAX_PROBES      16
  
 DS1820* probe[MAX_PROBES];
+Serial pc(USBTX, USBRX);
  
-int main() {  
+int main() 
+{  
+    pc.baud(115200);
+    pc.printf("Initialize probes...");
+    
     // Initialize the probe array to DS1820 objects
     int num_devices = 0;
     while(DS1820::unassignedProbe(DATA_PIN)) {
@@ -25,9 +30,9 @@
     while(1) {
         probe[0]->convertTemperature(true, DS1820::all_devices);         //Start temperature conversion, wait until ready
         for (int i = 0; i<num_devices; i++)
-            printf("Device %d returns %3.1foC\r\n", i, probe[i]->temperature());
+            printf("Device %d returns %3.1f oC", i, probe[i]->temperature());
         printf("\r\n");
-        wait(1);
+        wait_us(10000);
     }
     
 }
@@ -37,11 +42,17 @@
 #include "DS1820.h"
  
 DS1820 probe(DATA_PIN);
+Serial pc(USBTX, USBRX);
  
-int main() {
-    while(1) {
+int main() 
+{
+    pc.baud(115200);
+    pc.printf("Initialize probes...");
+    
+    while(1) 
+    {
         probe.convertTemperature(true, DS1820::all_devices);         //Start temperature conversion, wait until ready
-        printf("It is %3.1foC\r\n", probe.temperature());
+        pc.printf("It is %3.1foC\r\n", probe.temperature());
         wait(1);
     }
 }
diff -r 01060b5e01b4 -r 7cc3a5fc200d mbed-dev.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-dev.lib	Tue Aug 01 10:47:48 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-dev/#e3b6fe271b81
diff -r 01060b5e01b4 -r 7cc3a5fc200d mbed.bld
--- a/mbed.bld	Fri Jan 13 18:30:37 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/99b5ccf27215
\ No newline at end of file