fdrtgff

Dependencies:   HCSR04 awali2

Revision:
103:e61ad04d14f2
Parent:
102:2591f689e242
--- 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