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:
- 116:8b812e268b85
- Parent:
- 115:d8d2968981f3
- Child:
- 117:b1667291748d
diff -r d8d2968981f3 -r 8b812e268b85 main.cpp --- a/main.cpp Tue Oct 27 16:21:20 2015 +0100 +++ b/main.cpp Wed Oct 28 11:48:07 2015 +0100 @@ -14,20 +14,16 @@ #include "debug.h" #include "emg.h" -int a =4; - -Ticker switchesTick, debugTick, motorTick, EMGTick, safetyTick calibrateTick; -volatile bool switches_go=false, debug_go=false, motor_go=false, emg_go=false, safety_go=false, cal_go=false; +Ticker switchesTick, debugTick, motorTick, EMGTick, safetyTick; +volatile bool switches_go=false, debug_go=false, motor_go=false, emg_go=false, safety_go=false; void switches_activate(){switches_go=true;}; void debug_activate(){debug_go=true;}; void motor_activate(){motor_go=true;}; void emg_activate(){emg_go=true;}; void safety_activate(){safety_go=true;}; -void calibration_activate(){cal_go=true;}; void tickerAttach(){ - calibrateTick.detach(&calibration_activate); // stop calibration ticker EMGTick.attach(&emg_activate, 0.005f); switchesTick.attach(&switches_activate, 0.02f); debugTick.attach(&debug_activate, 0.03f); @@ -39,17 +35,14 @@ 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(); - calibrateTick.attach(&calibration_activate, motorCall); + calReady = calibrateMotors(); while (true) { - if(cal_go){ - cal_go=false; - calReady = calibrateMotors(); - } if(calReady && !tickersActivated){ // when done with calibration, start tickers tickerAttach();