raspai

Dependencies:   mbed SBDBT arrc_mbed Servo air

Revision:
1:1766ac88bf57
Parent:
0:b68d87850401
Child:
2:1d031514e4ff
diff -r b68d87850401 -r 1766ac88bf57 main.cpp
--- a/main.cpp	Fri Feb 25 04:50:23 2022 +0000
+++ b/main.cpp	Fri Mar 04 02:52:44 2022 +0000
@@ -5,13 +5,14 @@
 ScrpSlave slave(PC_12,PD_2,PH_1,SERIAL_TX,SERIAL_RX,0x0807ffff);
 Serial pc(SERIAL_TX,SERIAL_RX);
 DigitalIn limitA(PA_9,PullUp);
-Air hassya(PA_0);
+Air hassya(PB_8);
 DigitalOut Led1(PA_10);
 DigitalOut Led2(PB_15);
 DigitalOut Led3(PB_2);
-Servo myservo(PB_0);
+Servo myservo(PB_6);
 Timer timer;
-int tim=-3000;
+int tim=-6000;
+int a=0;
 //↓モータ用
 void driveMotorS(double pwm){
     PwmOut up_pin_A(PB_13);
@@ -34,42 +35,52 @@
     if(data==0){
     myservo = 0;
     }else{
-    myservo = 0.2;
+    myservo = 0.5;
     }
 }
 //↓発射用
 bool Hassya(int rx_data,int &tx_data){
-    if(rx_data == 1 && limitA==0){
+    
+    if(rx_data==1 && a==1){
         tim=timer.read_ms();
+        a=0;        
     }
-    if(timer.read_ms()-tim<1000){
+    if(a==1 && !limitA==0){
+        hassya.move(0);
+        driveMotorS(0);
+        Servo(0);
+        Led1.write(0);
+        Led2.write(0);
+        Led3.write(0);
+        a=1;
+    }else if(timer.read_ms()-tim<5000){
+            hassya.move(0);
+            driveMotorS(0);
+            Servo(1);
+            Led1.write(0);
+            Led2.write(0);
+            Led3.write(1);
+    }else if(timer.read_ms()-tim<6000){
             hassya.move(1);
             driveMotorS(0);
-            Servo(1);
+            Servo(0);
             Led1.write(1);
             Led2.write(0);
-            Led3.write(1);
-    }else if(timer.read_ms()-tim<2000){
+            Led3.write(0);
+    }else if(timer.read_ms()-tim>6000 && !limitA==1){
+            hassya.move(1);
+            driveMotorS(-0.06);
+            Servo(0);
+            Led1.write(1);
+            Led2.write(1);
+            Led3.write(0);
+    }else {
             hassya.move(0);
             driveMotorS(0);
             Servo(0);
             Led1.write(0);
             Led2.write(0);
             Led3.write(0);
-    }else if(timer.read_ms()-tim>2000 && limitA==1){
-            hassya.move(0);
-            driveMotorS(0.06);
-            Servo(0);
-            Led1.write(0);
-            Led2.write(1);
-            Led3.write(0);
-    }else {
-            hassya.move(1);
-            driveMotorS(0);
-            Servo(0);
-            Led1.write(1);
-            Led2.write(0);
-            Led3.write(0);
     }
     return true;
 }