![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
農作物回収機構プログラム
Dependencies: mbed arrc_mbed Motor
Diff: main.cpp
- Revision:
- 0:417f3396cf67
- Child:
- 1:7937f28c742d
diff -r 000000000000 -r 417f3396cf67 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Feb 02 11:27:13 2022 +0000 @@ -0,0 +1,38 @@ +//-----Libraries----- +#include "mbed.h" +#include "scrp_slave.hpp" +#include "motor.hpp" + +//-----Classes----- +ScrpSlave slave(PC_12, PD_2, PH_1, SERIAL_TX, SERIAL_RX, 4); //id: 4 +Motor motor(PB_14, PB_13); + +//-----Constants----- +const double pwm = 0.1; + +//-----Sub Routines----- +bool Up(int RX,int &TX); +bool Down(int RX,int &TX); + +//-----Variables----- +int up = 0; +int down = 0; + +//-----Main Routine----- +int main(){ + slave.addCMD(1, Up); + slave.addCMD(2, Down); + while(1){ + motor.out(pwm * (up + down)); + } +} + +bool Up(int RX, int &TX){ + up = RX; + return true; +} + +bool Down(int RX, int &TX){ + down = -RX; + return true; +} \ No newline at end of file