![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
control for robotic arm that can play chess using a granular gripper
Dependencies: Encoder mbed HIDScope Servo MODSERIAL
Fork of chessRobot by
Diff: main.cpp
- Revision:
- 111:43c0881fe7e7
- Parent:
- 110:a6439e13be8b
- Child:
- 117:b1667291748d
diff -r a6439e13be8b -r 43c0881fe7e7 main.cpp --- a/main.cpp Tue Oct 27 14:45:15 2015 +0000 +++ b/main.cpp Tue Oct 27 17:10:33 2015 +0000 @@ -14,8 +14,6 @@ #include "debug.h" #include "emg.h" -int a =4; - Ticker switchesTick, debugTick, motorTick, EMGTick, safetyTick; volatile bool switches_go=false, debug_go=false, motor_go=false, emg_go=false, safety_go=false; @@ -25,23 +23,32 @@ void emg_activate(){emg_go=true;}; void safety_activate(){safety_go=true;}; -double motorCall = 0.01; // set motor frequency global so it can be used for speed. -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 -bool calReady = false; // flag for calibration ready - -int main(){ - motorInit(); - calReady = calibrateMotors(); // start motor calibration - +void tickerAttach(){ 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); +} + +double motorCall = 0.01; // set motor frequency global so it can be used for speed. +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 +bool tickersActivated = false; +bool calReady = false; // flag for calibration ready + +int main(){ + motorInit(); + calReady = calibrateMotors(); while (true) { + + if(calReady && !tickersActivated){ // when done with calibration, start tickers + tickerAttach(); + tickersActivated = true; + } + if(emg_go){ emg_go=false; readEMG();