Silvie van den Bogaard
/
determine_x_setpoint
Determines the setpoint in x direction of the robot. Robot specific variables still have to be set.
main.cpp
- Committer:
- Duif
- Date:
- 2018-10-08
- Revision:
- 1:f120a8734106
- Parent:
- 0:0d70149fdb98
- Child:
- 2:8f1765df595c
File content as of revision 1:f120a8734106:
//Determining the setpoint that the thing will have to follow #include "mbed.h" #include "MODSERIAL.h" Ticker SetX; DigitalIn button(SW2); DigitalIn direction(SW3); MODSERIAL pc(USBTX, USBRX); //makes sure the computer is hooked up //defining of the variables static float x_prev = 0; //previous setpoint float x_new; //new setpoint float x_max; //maximum value of setpoint float x_min; //minimum value of setpoint float v; //moving speed of setpoint volatile int s; //value of the switch //equation is x_new = x_prev + s*v*dt //function that determines the setpoint of the x coordinate void EMGOn(){ x_new = x_prev + s*v; x_prev = x_new; pc.printf("Set: %f",x_new); } int main() { SetX.attach(EMGOn,1); //ticker to call the EMG function pc.baud(115200); while (true) { s = button.read(); //read value of the button pc.printf("Value: %i",s); //print the value of the button to check if it is correct } }