fdrtgff

Dependencies:   HCSR04 awali2

Files at this revision

API Documentation at this revision

Comitter:
timilrlan
Date:
Mon May 30 09:33:21 2022 +0000
Parent:
102:2591f689e242
Commit message:
dfd

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 2591f689e242 -r e61ad04d14f2 main.cpp
--- a/main.cpp	Thu May 26 06:11:34 2022 +0000
+++ b/main.cpp	Mon May 30 09:33:21 2022 +0000
@@ -7,10 +7,7 @@
 HCSR04 sensor(D12, D11);
 DigitalOut rele(D7);
 
-if (distance <= 0) {
-        printf("scan() failed with return value: %d\n", count);
-        return 0;
-    }
+
 #include "MQTTmbed.h"
 
 #include <MQTTClientMbedOs.h>
@@ -35,10 +32,15 @@
  void read_datchik_write_lcd_consol_publish_mqtt()
  {
       
+      
      
    /* EXAMPLE */
  long distance = sensor.distance();   
      printf("distance  %d  \n",distance);
+    if (distance>100)
+    rele=0;
+    if (distance<10)
+    rele=1;
     // initialize the LCD
     lcd.begin();
      
@@ -218,6 +220,14 @@
 
 int main(int argc, char *argv[])
  {
+     rele=0;
+  ThisThread::sleep_for(3000);
+  rele=1;
+  ThisThread::sleep_for(3000);
+  
+   
+     
+     
  //      pc.baud(115200);
     
     lpTicker.attach(tickerIRQ, 5); // every 5 second