cansat_B 2019 / Mbed 2 deprecated US015sb612Completed_renewal

Dependencies:   mbed

Revision:
2:d3675b786834
Parent:
1:d174c4427e69
Child:
3:f7f92004d3ac
--- a/main.cpp	Fri Nov 15 12:42:26 2019 +0000
+++ b/main.cpp	Wed Nov 27 14:17:36 2019 +0000
@@ -10,35 +10,44 @@
   float th;
   Timer tm;
   pc.printf("start\r\n");
-
-  bool detected=false;
-    thermo=0; //焦電off
-    Ultra=1;//超音波on
+  thermo=0; //焦電off
+  printf("焦電Off\r\n");
+  Ultra=1;//超音波on
+  printf("超音波On\r\n");
    
     while(1) {
          hs.TrigerOut();
          wait(1);
          int distance;
          distance = hs.GetDistance();
-         printf("%d\r\n",distance);//距離出力
+         printf("distance=%d\r\n",distance);//距離出力
         
-        if(distance<2000){//超音波反応
+        if(distance<=2000){//超音波反応
          Ultra=0;//超音波off
+
          thermo=1;//焦電on
-          if(true)
+          bool detected=false;
+          if(true){
              th = thermo;
              if(th=1 && !detected) {//焦電反応ありの場合
                detected=true;
              pc.printf("human\r\n");
              tm.reset();
              tm.start();
-            }else{//焦電反応なしの場合
+            }
+            else if(tm.read_ms()>5000){//焦電反応なしの場合
+             printf("not found\r\n");
              detected=false;
              }
            
-}
-  //while(true)
+          }
+        }if(distance>2000){//超音波反応遠い
+        printf("distance>2000だぞ\r\n");
+        }
+  //if(true)
   }
-  return 0;
-  }
+ 
+  
+   return 0;
+}
   
\ No newline at end of file