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:
98:25528494287d
Parent:
96:f0ae582fa3e1
Child:
99:7030e9790b1d
--- a/main.cpp	Thu Oct 22 07:16:59 2015 +0000
+++ b/main.cpp	Thu Oct 22 10:06:46 2015 +0200
@@ -24,41 +24,46 @@
 void safety_activate(){safety_go=true;};
 
 double motorCall = 0.01; // set motor frequency global so it can be used for speed.
-int main(){
-    while(1){
-    redLed.write(1); greenLed.write(0); blueLed.write(0);
-}
-motorInit();    
-calibrateMotors(); // start calibration procedure
+const int sample = 0;  // Constant for mode switching for program readability
+const int normalize = 1; // Constant for mode switching for program readability
+bool mode = normalize; // Set program mode
 
-switchesTick.attach(&switches_activate, 0.02f);
-debugTick.attach(&debug_activate, 0.03f);
-motorTick.attach(&motor_activate, motorCall);
-EMGTick.attach(&emg_activate, 0.005f);
-safetyTick.attach(&safety_activate, 0.001f);
+int main(){
+    motorInit();    
+    calibrateMotors(); // start motor calibration
 
+    EMGTick.attach(&emg_activate, 0.005f);
+    switchesTick.attach(&switches_activate, 0.02f);
+    debugTick.attach(&debug_activate, 0.03f);
+    motorTick.attach(&motor_activate, motorCall);
+    safetyTick.attach(&safety_activate, 0.001f);
 
     while (true) {
-        if(safety_go){
-            safety_go=false;
-            safety();
-        }
         if(emg_go){
             emg_go=false;
             readEMG();
         }
-        if(switches_go){
-            switches_go=false;
-            checkSwitches();
-        }
-        if(debug_go){
-            debug_go=false;
-            debugProcess();
-        }
-        if(motor_go){
-            motor_go=false;
-            motorControl();
-        // servoControl();
+        if(mode==0){  // wait until EMG is done with calibration
+            if(safety_go){
+                safety_go=false;
+                safety();
+            }
+            if(emg_go){
+                emg_go=false;
+                readEMG();
+            }
+            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