I want go to sea
Dependencies: arrc_mbed Servo air
Diff: main.cpp
- Revision:
- 2:fe26901d9d49
- Parent:
- 1:d3985e5af20f
- Child:
- 3:ccd2dd7d3814
diff -r d3985e5af20f -r fe26901d9d49 main.cpp --- a/main.cpp Fri Mar 11 00:45:18 2022 +0000 +++ b/main.cpp Sat Mar 12 01:21:35 2022 +0000 @@ -7,7 +7,7 @@ DigitalIn limitA(PB_6,PullUp); DigitalIn limitB(PB_12,PullUp); Air catch_no(PA_9); -//Air catch_no2(PA_7); +Air catch_no2(PA_7); //Air catch_no3(PA_6); DigitalIn limitC(PB_4,PullUp); @@ -18,6 +18,8 @@ bool limit_switch = true; int date=0; int air_date=0; +int air_date2=0; +int a=0; void driveMotorS2(double pwm){ @@ -41,21 +43,20 @@ if(data==0){ myservo = 0; }else{ - myservo = 0.2; + myservo = 0.5; } } //↓発射用 -int a=0; bool Hassya(int rx_data,int &tx_data){ - if(rx_data==1 /*&& a==1*/){ + if(rx_data==1 && a==1){ tim=timer.read_ms(); a=0; } - if(a==1 && !limitA==0){ - hassya.move(0); - driveMotorS2(0); - Servo(0); - a=1; + if(a==1 || !limitC==0){ + hassya.move(0); + driveMotorS2(0); + Servo(0); + a=1; }else if(timer.read_ms()-tim<5000){ hassya.move(0); driveMotorS2(0); @@ -64,11 +65,11 @@ hassya.move(1); driveMotorS2(0); Servo(0); - }else if(timer.read_ms()-tim>6000 && !limitA==1){ + }else if(timer.read_ms()-tim>6000 && !limitC==1){ hassya.move(1); driveMotorS2(-0.06); Servo(0); - }else { + }else{ hassya.move(0); driveMotorS2(0); Servo(0); @@ -104,9 +105,9 @@ date=-1 ; } if(date==1 && !limitA){ - driveMotorS(0.6); + driveMotorS(0.4); }else if(date==-1 && !limitB){ - driveMotorS(-0.6); + driveMotorS(-0.4); }else{ driveMotorS(0); } @@ -116,15 +117,16 @@ bool CATCH_NO(int rx_data,int &tx_data){ if(tx_data==1){ air_date+=1; - }else if(tx_data==2&&air_date==0){ + }else if(tx_data==2&&(air_date%2)==0){ air_date=1; } catch_no.move(air_date%2); return true; - } +} bool CATCH_NO2(int rx_data,int &tx_data){ - //catch_no2.move(rx_data); + air_date+=tx_data; + catch_no2.move(air_date%2); //catch_no3.move(rx_data); return true; }