ニョロゾ

Dependencies:   mbed BMP180

Revision:
5:eedb48931268
Parent:
4:e84fb33d8c2b
Child:
6:f862230de7b5
--- a/main.cpp	Thu Dec 17 17:44:55 2020 +0000
+++ b/main.cpp	Fri Dec 18 01:49:10 2020 +0000
@@ -10,8 +10,9 @@
 
 Serial pc(SERIAL_TX,SERIAL_RX,921600);//通信
 Serial xbee(D1,D0);//Xbeeのピン
-DigitalOut FET(D9);//FETのピン
-DigitalIn flight(D6);  //フライトピンのピン    
+DigitalOut FET1(D9);//FETのピン
+DigitalOut FET2(D8);
+DigitalIn flight(D6);    
 DigitalOut SW(D7);//フライトピンの電圧降下ピン 
 TB6612 motor(D7,D9,D11);//モータードライバーのピン
 GPS gps (D1,D0);                 
@@ -19,7 +20,8 @@
 
   int main(){
     float x8;
-    FET=0;
+    FET1=0;
+    FET2=0;
     SW=1;
     flight==1;//フライトピンがついている
     motor=0;
@@ -37,6 +39,8 @@
         else{
 
         SW = 0;
+        FET2=1;
+        wait(25);
         pc.printf("やったぞおおおおおおおおお!\n");
   
     break;
@@ -105,20 +109,20 @@
                     }
            }
            /*speedが0以下になったらFETに20秒電流を流してその後電流を止める*/         
-/* FET=1;
+ FET1=1;
 wait(20);
-FET=0;*/
+FET1=0;
 motor = 100; 
-/*double a;
+double a;
     double b;
     double distance;
     
      pc.printf("GPS begin\n");
     
     while(1){
-        if(gps.getgps()){*/
+        if(gps.getgps()){
             /*a,bを緯度経度の初期値で初期化*/
-           /* a=gps.latitude;
+            a=gps.latitude;
             b=gps.longitude;
             pc.printf("(%lf,%lf)\r\n",gps.latitude,gps.longitude);//緯度と経度を表示
             pc.printf("--------------------------------\n\r");
@@ -131,19 +135,19 @@
          while(1){
          if(gps.getgps()){
              pc.printf("(%lf,%lf)\n\r",gps.latitude,gps.longitude);//緯度と経度を表示
-            pc.printf("--------------------------------\n\r");
-      */       
+            pc.printf("--------------------------------\n\r");   
     /*ここから距離の計算*/
                  /*c、dを得た緯度経度の値で初期化*/  
-                     /*double c;
+                     double c;
                       double d;
                       c=gps.latitude;
                       d=gps.longitude;
-                      */
-                      //const double pi=3.14159265359;//円周率
+                      
+                      
+                      const double pi=3.14159265359;//円周率
                       
                       /*ラジアンに変換*/
-                    /*  double theta_a=a*pi/180;
+                     double theta_a=a*pi/180;
                       double theta_b=b*pi/180;
                       double theta_c=c*pi/180;
                       double theta_d=d*pi/180;
@@ -154,9 +158,9 @@
                       const double earth_radius=6378140;//赤道半径
                       
                       distance=earth_radius*theta_r;//距離の計算
-                      */
+                      
              /*距離が25m以上なら表示、通信*/         
-                /* if(distance>=30){
+                 if(distance>=30){
                   pc.printf("run over 20m");
                   motor=0;
                   pc.printf("run over 20m");
@@ -169,7 +173,7 @@
                 wait(1);
             }//データ取得失敗を表示、通信、1秒待機
                
-               }*/
+               }
     pc.printf("成功\n");
    return 0;
    }
\ No newline at end of file