農作物回収機構プログラム

Dependencies:   mbed arrc_mbed Motor

Revision:
0:417f3396cf67
Child:
1:7937f28c742d
--- /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