Simple DS1820 sensor demo showing how to use the DS1820 library [https://developer.mbed.org/users/hudakz/code/DS1820/]

Dependencies:   DS1820 mbed

Fork of DS1820_Hello by Zoltan Hudak

Files at this revision

API Documentation at this revision

Comitter:
paris8022
Date:
Wed Nov 01 02:29:37 2017 +0000
Parent:
3:eb195375cde7
Commit message:
t watersensor

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r eb195375cde7 -r 9afd6251d15e main.cpp
--- a/main.cpp	Fri Mar 27 12:37:34 2015 +0000
+++ b/main.cpp	Wed Nov 01 02:29:37 2017 +0000
@@ -9,6 +9,9 @@
 #include "mbed.h"
 #include "DS1820.h"
 
+DigitalOut ledpin(LED1); 
+DigitalIn  sensor_in(D4);
+
 Serial serial(USBTX, USBRX);
  
 int main() {
@@ -24,9 +27,26 @@
         }
     } else
         serial.printf("No DS1820 sensor found!\r\n");
+
+      
+    while(1) {
+        // LEDs are ON
+        if(sensor_in)
+        {
+            ledpin = 1;
+            serial.printf("LED:ON\n");     
+            wait(1.2);
+        }
+        else
+        {
+        // LEDs are OFF
+            ledpin = 0;
+           serial.printf("LED:OFF\n");
+            wait(1.4);
+        }
+  }
 }
 
-
 // You can create an array of sensors:
 
 //int main() {