Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 17:9ee4c69d2d8b
- Parent:
- 16:04f42eeb9561
- Child:
- 18:c61ba21bbc67
--- a/main.cpp Wed Jan 26 16:16:41 2022 +0000
+++ b/main.cpp Thu Jan 27 07:29:51 2022 +0000
@@ -17,9 +17,9 @@
DigitalIn limit_1(PA_9);//リミットスイッチ1
DigitalIn limit_2(PA_8);//リミットスイッチ2
-int shoot_phase;//発射フェーズ 0:待機 1:装填動作 2:リボルバー回転、モーター復帰(同時) 3:発射
-bool turn_able;//回転可否 0:待機 1:回転
-bool back_able;
+int shoot_phase = 0;//発射フェーズ 0:待機 1:装填動作 2:リボルバー回転、モーター復帰(同時) 3:発射
+bool turn_able = 0;//回転可否 0:待機 1:回転
+bool back_able = 0;//復帰可否
double revolver_pwm = -0.03;//リボルバー回転速度
double load_pwm = -0.3;//装填モーター速度
@@ -44,7 +44,7 @@
if(count == 1){
motor_revolver.output(0);
turn_able = 0;
- printf("finished turnning\n");
+ printf("no turn\n");
}
if(count != 1){
if(roricon < 341 * (count - 1)){
@@ -75,13 +75,12 @@
if(turn_able == 0 && turn_able == 0){
break;
}
- wait(0.01);
+ wait(0.1);
}
}
int main(){
int count = 1;//何発目か
- shoot_phase = 0;
servo.period_us(20000);
limit_1.mode(PullUp);
@@ -105,10 +104,10 @@
while(limit_1.read() == 0){
motor_shoot.output(load_pwm);
printf("loading\n");
- wait(0.1);
if(limit_2.read() == 1){
break;
}
+ wait(0.1);
}
motor_shoot.output(0);
shoot_phase = 2;
@@ -120,15 +119,14 @@
turn_able = 1;
back_able = 1;
revolver_back(count);
+ shoot_phase = 3;
printf("finished backing\n");
- shoot_phase = 3;
+ wait(3);
break;
case 3://発射動作
- wait(3);
servo.pulsewidth_us(theta_45);
- printf("finished shooting %d shot\n",count);
- count ++;
+ printf("%d shot\n",count);
wait(3);
servo.pulsewidth_us(theta_0);
motor_shoot.output(load_pwm);
@@ -136,6 +134,7 @@
motor_shoot.output(0);
shoot_phase = 0;
printf("finished init\n");
+ count ++;
break;
}
}