control for robotic arm that can play chess using a granular gripper

Dependencies:   Encoder mbed HIDScope Servo MODSERIAL

Fork of chessRobot by a steenbeek

Revision:
30:a20f16bf8dda
Parent:
29:e4f3455aaa0b
Child:
31:8fbee6c92753
diff -r e4f3455aaa0b -r a20f16bf8dda main.cpp
--- a/main.cpp	Tue Oct 06 17:55:11 2015 +0000
+++ b/main.cpp	Tue Oct 06 21:06:20 2015 +0000
@@ -9,20 +9,33 @@
 #include "debug.h"
 
 
-Ticker debugsend;
+Ticker switches, debug, motor;
+volatile bool switches_go=false, debug_go=false, motor_go=false;
 
+void switches_activate(){switches_go=true;};
+void debug_activate(){debug_go=true;};
+void motor_activate(){motor_go=true;};
 
 int main(){
 motorInit(); 
 
-//debugsend.attach(&debugProcess, 0.2);
-
+switches.attach(&switches_activate, 0.19f);
+debug.attach(&debug_activate, 0.21f);
+motor.attach(&motor_activate, 0.2f);
     while (true) {
-        checkSwitches();
         // readEMG();
-        motorControl();
         // servoControl();
-        debugProcess();
-        wait(0.2f);
+        if(switches_go){
+            switches_go=false;
+            checkSwitches();
+        }
+        if(debug_go){
+            debug_go=false;
+            debugProcess();
+        }
+        if(motor_go){
+            motor_go=false;
+            motorControl();
+        }
     }
 }
\ No newline at end of file