program to shoot beenbags

Dependencies:   mbed MOTOR

arrcmbedをインクルードしてください。

Revision:
4:d71a97acbf01
Parent:
3:326387780345
Child:
5:1433a73c2692
--- a/main.cpp	Thu Jan 13 14:19:49 2022 +0000
+++ b/main.cpp	Fri Jan 14 14:46:00 2022 +0000
@@ -7,7 +7,7 @@
 //ScrpSlave slave(PA_9,PA_10,PA_12,SERIAL_TX,SERIAL_RX,0x0803f800);//l432kc
 ScrpSlave slave(PC_12,PD_2,PH_1,SERIAL_TX,SERIAL_RX,0x0807f800);//f446re
 
-RotaryInc roricon(PA_6,PA_7,1,1024,4);
+RotaryInc v(PA_14,PA_15,1,1024,4);
 
 Motor motor_revolver(PB_13,PB_14);//リボルバーモーター
 Motor motor_shoot(PA_11,PB_1);//発射機構モーター
@@ -17,6 +17,7 @@
 
 double revolver_pwm = 0.1;//リボルバー回転速度
 double interval = 0.1;
+int roricon = 0;
 
 bool interrupt(int rx_data,int &tx_data){
     if(shoot_able == 0){//フェーズ0以外は、発射できないように
@@ -25,6 +26,7 @@
     return true;  
 }
 
+int a;
 //リボルバーP制御関数
 //double k_p = 0.001;
 //double target = 171.0;
@@ -46,9 +48,10 @@
 
 void revolver(int count){
     if(turn_able == 1){
-        while(roricon.get() < 171 * count){
+        while(roricon < 171 * count){
+            roricon = v.get();
             motor_revolver.output(revolver_pwm);
-            printf("roricon = %lf\n",roricon.get());
+            printf("roricon = %d\n",roricon);
             wait(interval);
         }
         motor_revolver.output(0.0);
@@ -68,13 +71,13 @@
                 wait(0.1);
                 printf("waiting\n");  
             }
-            printf("finished waiting");  
+            printf("finished waiting\n");  
             break;
             
             case 1:
             //装填動作コードをここに書く!
             shoot_able = 2;
-            printf("finished pulling"); 
+            printf("finished pulling\n"); 
             break;
             
             case 2:
@@ -84,14 +87,14 @@
             if(turn_able == 0){
                 shoot_able = 3;
             }
-            printf("finished turnning");  
+            printf("finished turnning\n");  
             break;
             
             case 3:
             //発射動作コードをここに書く!
             shoot_able = 0;
+            printf("finished shooting %d\n",count);  
             count ++;
-            printf("finished shooting");  
             break;
         } 
     }