cansat_B 2019 / Mbed 2 deprecated US015sb612Completed_Real

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
YUPPY
Date:
Fri Nov 22 07:56:18 2019 +0000
Parent:
1:d174c4427e69
Commit message:
matome;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Fri Nov 15 12:42:26 2019 +0000
+++ b/main.cpp	Fri Nov 22 07:56:18 2019 +0000
@@ -5,6 +5,7 @@
 DigitalOut thermo(p20);
 DigitalOut Ultra(p12);
 Serial pc(USBTX,USBRX); // tx, rx
+void us015(void);
 
 int main(){
   float th;
@@ -16,12 +17,8 @@
     Ultra=1;//超音波on
    
     while(1) {
-         hs.TrigerOut();
-         wait(1);
-         int distance;
-         distance = hs.GetDistance();
-         printf("%d\r\n",distance);//距離出力
-        
+          int distance;
+          us015();
         if(distance<2000){//超音波反応
          Ultra=0;//超音波off
          thermo=1;//焦電on
@@ -39,6 +36,14 @@
 }
   //while(true)
   }
-  return 0;
+  
   }
-  
\ No newline at end of file
+   void us015(){
+    hs.TrigerOut();
+         wait(1);
+         int distance;
+         distance = hs.GetDistance();
+         printf("%d\r\n",distance);//距離出力
+         }
+
+ 
\ No newline at end of file