EVGENIY BREYNER / Mbed 2 deprecated FROST

Dependencies:   mbed DS1820

Files at this revision

API Documentation at this revision

Comitter:
zbr2006
Date:
Wed Dec 11 13:58:25 2019 +0000
Commit message:
test

Changed in this revision

DS1820.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DS1820.lib	Wed Dec 11 13:58:25 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/marcozecchini/code/DS1820/#ff713869139a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Dec 11 13:58:25 2019 +0000
@@ -0,0 +1,36 @@
+#include "mbed.h"
+ #include "DS1820.h"
+ 
+ Serial      pc(USBTX, USBRX);
+ DigitalOut  led(LED1);
+ DS1820      ds1820(D8);  // substitute D8 with actual mbed pin name connected to 1-wire bus
+ float       temp = 0;
+ int         result = 0;
+ 
+ int main()
+ {
+     pc.printf("\r\n--Starting--\r\n");
+     if (ds1820.begin()) {
+         while (1) {
+             ds1820.startConversion();   // start temperature conversion from analog to digital
+             wait(1.0);                  // let DS1820 complete the temperature conversion
+             result = ds1820.read(temp); // read temperature from DS1820 and perform cyclic redundancy check (CRC)
+             switch (result) {
+                 case 0:                 // no errors -> 'temp' contains the value of measured temperature
+                     pc.printf("temp = %3.1f%cC\r\n", temp, 176);
+                     break;
+ 
+                 case 1:                 // no sensor present -> 'temp' is not updated
+                     pc.printf("no sensor present\n\r");
+                     break;
+ 
+                 case 2:                 // CRC error -> 'temp' is not updated
+                     pc.printf("CRC error\r\n");
+             }
+ 
+             led = !led;
+         }
+     }
+     else
+         pc.printf("No DS1820 sensor found!\r\n");
+ }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Dec 11 13:58:25 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file