Silvie van den Bogaard
/
determine_x_setpoint
Determines the setpoint in x direction of the robot. Robot specific variables still have to be set.
Diff: main.cpp
- Revision:
- 1:f120a8734106
- Parent:
- 0:0d70149fdb98
- Child:
- 2:8f1765df595c
--- a/main.cpp Mon Oct 08 15:27:21 2018 +0000 +++ b/main.cpp Mon Oct 08 15:39:06 2018 +0000 @@ -1,12 +1,13 @@ //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 -float x_prev = 0; //previous setpoint +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 @@ -15,6 +16,7 @@ //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; @@ -23,9 +25,11 @@ int main() { + SetX.attach(EMGOn,1); //ticker to call the EMG function pc.baud(115200); while (true) { - s = button.read(); + 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 } }