shoot
Dependencies: mbed SBDBT arrc_mbed Servo air
main.cpp
- Committer:
- asumamatsumura
- Date:
- 2022-01-24
- Revision:
- 1:cae30876c429
- Parent:
- 0:6f9a457b09e1
- Child:
- 2:0428390d7c90
File content as of revision 1:cae30876c429:
#include "mbed.h" #include "air.hpp" #include "sbdbt.hpp" sbdbt ds3(A0, A1); DigitalIn limitA(PA_9,PullUp); Air hassya(PA_0); Timer timer; //↓モータ用 void driveMotorS(double pwm){ PwmOut up_pin_A(PB_13); PwmOut up_pin_B(PB_14); up_pin_A.period_us(2048); up_pin_B.period_us(2048); if (!pwm) { up_pin_A = 0; up_pin_B = 0; } else if (0 < pwm) { up_pin_A = pwm; up_pin_B = 0; } else { up_pin_A = 0; up_pin_B= -pwm; } } // ↓サーボ用(未実装) void Servo(bool data){ } //↓発射用 void Hassya(bool data,int tim){ if(data==1 || timer.read_ms()-tim<3000){ if(timer.read_ms()-tim>2000){ hassya.move(1); }else{ hassya.move(0); } if(timer.read_ms()-tim>1000) Servo(1); }else{ if(limitA){ driveMotorS(0); Servo(0); }else{ driveMotorS(0.06); } } } int main(){ //↓宣言 bool shoot; int tim,old_square=0; timer.start(); while(true){ //コントローラ関係 if(old_square<ds3.square() && (!shoot || limitA)){ shoot=!shoot; tim=timer.read_ms(); } old_square=ds3.square(); //関数 Hassya(shoot,tim); } }