Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: biquadFilter FastPWM HIDScope MODSERIAL mbed
Fork of StateMachine by
test.cpp
- Committer:
- tverouden
- Date:
- 2018-10-31
- Revision:
- 0:c0c35b95765f
- Child:
- 2:d70795e4e0bf
File content as of revision 0:c0c35b95765f:
void StateMachine(){ switch(CurrentState){ //Determine in which state you are case Calibration: //Calibration mode if(StateBool){ //If you go into this state pc.printf("You can start calibrating. \n\r"); //Print that you are in this state StateBool = false; //Set the bool for the start of a state to false EMGCalibration_timer.attach(&CalibrateEMG,0.005); //Start EMG calibration every 0.005 seconds FindMax_timer.attach(&FindMax,15); //Find the maximum value after 15 seconds SwitchState_timer.attach(&SwitchState,16); //Switch to the next state after 16 seconds blueled = 0; } if (SwitchStateBool){ //If the bool is changed CurrentState = WorkingMode; //Change the state to the working mode StateBool = true; //Set the start of a state bool to true SwitchStateBool = false; //Set the switch bool to false } break; case WorkingMode: //Mode to get the robot working if (StateBool){ //If you start to go in this state pc.printf("You are know in the working mode. \r\n"); //Print in which mode you are StateBool = false; //Set the start of state bool to true EMGCalibration_timer.detach(); //Detach the the calibration ReadUseEMG_timer.attach(&ReadUseEMG, 0.005); //Start the use of EMG } blueled = 1; //Set the blue led off pc.printf("%f \n\r",EMG0Average); break; } } void SwitchState(){ SwitchStateBool = true; //Set the bool for the start of a state to true SwitchState_timer.detach(); //Use this function once } // PC-communication bool externalPC = true; // toggle communication with external PC if externalPC { MODSERIAL pc(USBTX, USBRX);