kakuninonegai
Dependencies: mbed SBDBT arrc_mbed air
Diff: main.cpp
- Revision:
- 0:b03df060dbea
- Child:
- 1:bf629e5bf337
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Jan 18 08:27:37 2022 +0000 @@ -0,0 +1,50 @@ +#include "mbed.h" +#include "scrp_slave.hpp" +#include "air.hpp" +#include "sbdbt.hpp" +sbdbt ds3(A0, A1); +DigitalIn limitA(PA_9,PullUp); +DigitalIn limitB(PC_5,PullUp); +Air catch_no(PA_0); + +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 Up(int data){ + if(data==1 && !limitA){ + driveMotorS(0.06); + }else if(data==-1 && !limitB){ + driveMotorS(-0.06); + }else{ + driveMotorS(0); + } +} +void CATCH_NO(bool data){ + catch_no.move(data); + } + +int main(){ + int up; + bool catch_no=0,old_circle; + while(true){ + up=ds3.up()+ds3.down(); + if(old_circle<ds3.circle()) catch_no=!catch_no; + old_circle=ds3.circle(); + + Up(up); + CATCH_NO(catch_no); + } +} \ No newline at end of file