emg with text

Dependencies:   HIDScope MODSERIAL biquadFilter mbed

Fork of emg_import by Daniqe Kottelenberg

Committer:
daniQQue
Date:
Tue Nov 01 10:30:56 2016 +0000
Revision:
42:7164ccd2aa14
Parent:
41:9ea3d5921f07
Child:
43:7d0b2dc05b80
lampjes erin, kalibratie, knippert nog

Who changed what in which revision?

UserRevisionLine numberNew contents of line
daniQQue 0:34c739fcc3e0 1 //libraries
daniQQue 0:34c739fcc3e0 2 #include "mbed.h"
daniQQue 0:34c739fcc3e0 3 #include "HIDScope.h"
daniQQue 14:5b17697cf775 4 #include "BiQuad.h"
daniQQue 40:187ef29de53d 5 #include "MODSERIAL.h"
daniQQue 0:34c739fcc3e0 6
daniQQue 0:34c739fcc3e0 7 //Define objects
daniQQue 40:187ef29de53d 8 AnalogIn emg_biceps_right_in( A0 ); //analog in to get EMG biceps (r) in to c++
daniQQue 40:187ef29de53d 9 AnalogIn emg_triceps_right_in(A1); //analog in to get EMG triceps (r) in to c++
daniQQue 40:187ef29de53d 10 AnalogIn emg_biceps_left_in (A2); //analog in to get EMG biceps (l) in to c++
daniQQue 42:7164ccd2aa14 11
daniQQue 42:7164ccd2aa14 12 InterruptIn button_calibration_biceps (SW3); //button to start calibration biceps
daniQQue 42:7164ccd2aa14 13 InterruptIn button_calibration_triceps (SW2); // button to start calibration tricps
daniQQue 42:7164ccd2aa14 14
daniQQue 0:34c739fcc3e0 15 Ticker sample_timer; //ticker
daniQQue 40:187ef29de53d 16 Ticker switch_function; //ticker
daniQQue 40:187ef29de53d 17 HIDScope scope(5); //open 3 channels in hidscope
daniQQue 40:187ef29de53d 18 MODSERIAL pc(USBTX, USBRX); //pc connection
daniQQue 40:187ef29de53d 19 DigitalOut red(LED_RED);
daniQQue 40:187ef29de53d 20 DigitalOut green(LED_GREEN);
daniQQue 42:7164ccd2aa14 21 DigitalOut blue(LED_BLUE);
daniQQue 40:187ef29de53d 22 //motors
daniQQue 40:187ef29de53d 23 DigitalOut richting_motor1(D4);
daniQQue 40:187ef29de53d 24 PwmOut pwm_motor1(D5);
daniQQue 40:187ef29de53d 25 DigitalOut richting_motor2(D7);
daniQQue 40:187ef29de53d 26 PwmOut pwm_motor2(D6);
daniQQue 0:34c739fcc3e0 27
daniQQue 0:34c739fcc3e0 28 //define variables
daniQQue 40:187ef29de53d 29 //other
daniQQue 41:9ea3d5921f07 30 int onoffsignal_biceps=0; // on/off signal: 1; biceps activation, 0: nothing, -1, triceps activation
daniQQue 41:9ea3d5921f07 31 int switch_signal_triceps=0; // switching between motors.
daniQQue 42:7164ccd2aa14 32 volatile double cut_off_value_biceps_right =0.04; //gespecificeerd door floortje
daniQQue 42:7164ccd2aa14 33 volatile double cut_off_value_biceps_left =-0.04;
daniQQue 42:7164ccd2aa14 34 volatile double cut_off_value_triceps=0.04; //gespecificeerd door floortje
daniQQue 41:9ea3d5921f07 35 double signal_biceps_sum;
daniQQue 42:7164ccd2aa14 36 int motorswitch= 0; //start van de teller wordt op nul gesteld
daniQQue 42:7164ccd2aa14 37
daniQQue 42:7164ccd2aa14 38 //variables and constants for calibration
daniQQue 42:7164ccd2aa14 39 const float percentage_max_triceps=0.3;
daniQQue 42:7164ccd2aa14 40 const float percentage_max_biceps =0.3;
daniQQue 42:7164ccd2aa14 41 double max_biceps; //calibration maximum biceps
daniQQue 42:7164ccd2aa14 42 double max_triceps; //calibration maximum triceps
daniQQue 42:7164ccd2aa14 43
daniQQue 40:187ef29de53d 44 //biceps arm 1, right arm
daniQQue 15:bb4a6c7836d8 45 double emg_biceps_right;
daniQQue 15:bb4a6c7836d8 46 double emg_filtered_high_biceps_right;
daniQQue 15:bb4a6c7836d8 47 double emg_abs_biceps_right;
daniQQue 15:bb4a6c7836d8 48 double emg_filtered_biceps_right;
daniQQue 40:187ef29de53d 49 double emg_filtered_high_notch_1_biceps_right;
daniQQue 40:187ef29de53d 50 //double emg_filtered_high_notch_1_2_biceps_right;
daniQQue 40:187ef29de53d 51
daniQQue 40:187ef29de53d 52 //triceps arm 1, right arm
daniQQue 40:187ef29de53d 53 double emg_triceps_right;
daniQQue 40:187ef29de53d 54 double emg_filtered_high_triceps_right;
daniQQue 40:187ef29de53d 55 double emg_abs_triceps_right;
daniQQue 40:187ef29de53d 56 double emg_filtered_triceps_right;
daniQQue 40:187ef29de53d 57 double emg_filtered_high_notch_1_triceps_right;
daniQQue 40:187ef29de53d 58
daniQQue 40:187ef29de53d 59 //biceps arm 1, left arm
daniQQue 40:187ef29de53d 60 double emg_biceps_left;
daniQQue 40:187ef29de53d 61 double emg_filtered_high_biceps_left;
daniQQue 40:187ef29de53d 62 double emg_abs_biceps_left;
daniQQue 40:187ef29de53d 63 double emg_filtered_biceps_left;
daniQQue 40:187ef29de53d 64 double emg_filtered_high_notch_1_biceps_left;
daniQQue 40:187ef29de53d 65
daniQQue 40:187ef29de53d 66 //before abs filtering
daniQQue 40:187ef29de53d 67
daniQQue 40:187ef29de53d 68 //b1 = biceps right arm
daniQQue 40:187ef29de53d 69 BiQuad filterhigh_b1(9.5654e-01,-1.9131e+00,9.5654e-01,-1.9112e+00,9.1498e-01);
daniQQue 40:187ef29de53d 70 BiQuad filternotch1_b1 (9.9376e-01 , -1.8902e-00, 9.9376e-01 , -1.8902e-00 , 9.875e-01);
daniQQue 40:187ef29de53d 71
daniQQue 40:187ef29de53d 72 //t1= triceps right arm
daniQQue 40:187ef29de53d 73 BiQuad filterhigh_t1(9.5654e-01,-1.9131e+00,9.5654e-01,-1.9112e+00,9.1498e-01);
daniQQue 40:187ef29de53d 74 BiQuad filternotch1_t1 (9.9376e-01 , -1.8902e-00, 9.9376e-01 , -1.8902e-00 , 9.875e-01);
daniQQue 5:688b1b5530d8 75
daniQQue 40:187ef29de53d 76 //b2= biceps left arm
daniQQue 40:187ef29de53d 77 BiQuad filterhigh_b2(9.5654e-01,-1.9131e+00,9.5654e-01,-1.9112e+00,9.1498e-01);
daniQQue 40:187ef29de53d 78 BiQuad filternotch1_b2 (9.9376e-01 , -1.8902e-00, 9.9376e-01 , -1.8902e-00 , 9.875e-01);
daniQQue 40:187ef29de53d 79
daniQQue 40:187ef29de53d 80 //after abs filtering
daniQQue 40:187ef29de53d 81 BiQuad filterlow_b1 (6.2942e-06, 1.2588e-05,6.2942e-06,-1.9929e+00,9.9292e-01);
daniQQue 40:187ef29de53d 82 BiQuad filterlow_t1 (6.2942e-06, 1.2588e-05,6.2942e-06,-1.9929e+00,9.9292e-01);
daniQQue 40:187ef29de53d 83 BiQuad filterlow_b2 (6.2942e-06, 1.2588e-05,6.2942e-06,-1.9929e+00,9.9292e-01);
daniQQue 10:7255b59224cc 84
daniQQue 40:187ef29de53d 85 //function teller
daniQQue 40:187ef29de53d 86 void SwitchN() { // maakt simpele functie die 1 bij n optelt
daniQQue 41:9ea3d5921f07 87 if(switch_signal_triceps==1)
daniQQue 40:187ef29de53d 88 {
daniQQue 42:7164ccd2aa14 89 motorswitch++;
daniQQue 42:7164ccd2aa14 90
daniQQue 42:7164ccd2aa14 91 if (motorswitch%2==0)
daniQQue 42:7164ccd2aa14 92 {pc.printf("If you contract the right arm, the robot will go right \r\n");
daniQQue 42:7164ccd2aa14 93 pc.printf("If you contract biceps of the left arm, the robot will go left \r\n");
daniQQue 42:7164ccd2aa14 94 pc.printf("\r\n");
daniQQue 42:7164ccd2aa14 95 green=0;
daniQQue 42:7164ccd2aa14 96 red=1;
daniQQue 42:7164ccd2aa14 97 }
daniQQue 42:7164ccd2aa14 98
daniQQue 42:7164ccd2aa14 99 else
daniQQue 42:7164ccd2aa14 100 {pc.printf("If you contract the biceps of right arm, the robot will go up \r\n");
daniQQue 41:9ea3d5921f07 101 pc.printf("If you contract the biceps of left arm, the robot will go down \r\n");
daniQQue 41:9ea3d5921f07 102 pc.printf("\r\n");
daniQQue 42:7164ccd2aa14 103 green=1;
daniQQue 42:7164ccd2aa14 104 red=0;
daniQQue 42:7164ccd2aa14 105
daniQQue 40:187ef29de53d 106 }
daniQQue 42:7164ccd2aa14 107
daniQQue 40:187ef29de53d 108 }
daniQQue 41:9ea3d5921f07 109 }
daniQQue 40:187ef29de53d 110
daniQQue 40:187ef29de53d 111 //functions which are called in ticker to sample the analog signal
daniQQue 40:187ef29de53d 112
daniQQue 42:7164ccd2aa14 113 //callibration
daniQQue 42:7164ccd2aa14 114 void calibration_biceps(){
daniQQue 42:7164ccd2aa14 115 pc.printf("start of calibration biceps, contract maximal \n");
daniQQue 42:7164ccd2aa14 116 red=1;
daniQQue 42:7164ccd2aa14 117 green=1;
daniQQue 42:7164ccd2aa14 118 blue=0;
daniQQue 42:7164ccd2aa14 119
daniQQue 42:7164ccd2aa14 120 for(int n =0; n<3000;n++) //read for 2000 samples as calibration
daniQQue 42:7164ccd2aa14 121 {
daniQQue 42:7164ccd2aa14 122 emg_biceps_right=emg_biceps_right_in.read(); //read the emg value from the elektrodes
daniQQue 42:7164ccd2aa14 123 emg_filtered_high_biceps_right= filterhigh_b1.step(emg_biceps_right);
daniQQue 42:7164ccd2aa14 124 emg_filtered_high_notch_1_biceps_right=filternotch1_b1.step(emg_filtered_high_biceps_right);
daniQQue 42:7164ccd2aa14 125 emg_abs_biceps_right=fabs(emg_filtered_high_notch_1_biceps_right); //fabs because float
daniQQue 42:7164ccd2aa14 126 emg_filtered_biceps_right=filterlow_b1.step(emg_abs_biceps_right);
daniQQue 42:7164ccd2aa14 127
daniQQue 42:7164ccd2aa14 128 if (emg_filtered_biceps_right > max_biceps) //determine what the highest reachable emg signal is
daniQQue 42:7164ccd2aa14 129 {
daniQQue 42:7164ccd2aa14 130 max_biceps = emg_filtered_biceps_right;
daniQQue 42:7164ccd2aa14 131
daniQQue 42:7164ccd2aa14 132 }
daniQQue 42:7164ccd2aa14 133 wait(0.001f); //to sample at same freq; 1000Hz
daniQQue 42:7164ccd2aa14 134 }
daniQQue 42:7164ccd2aa14 135 cut_off_value_biceps_right=percentage_max_biceps*max_biceps;
daniQQue 42:7164ccd2aa14 136 cut_off_value_biceps_left=-cut_off_value_biceps_right;
daniQQue 42:7164ccd2aa14 137 //toggle lights
daniQQue 42:7164ccd2aa14 138 blue=!blue;
daniQQue 42:7164ccd2aa14 139
daniQQue 42:7164ccd2aa14 140 pc.printf(" end of calibration\r\n",cut_off_value_biceps_right );
daniQQue 42:7164ccd2aa14 141 pc.printf(" change of cv biceps: %f ",cut_off_value_biceps_right );
daniQQue 42:7164ccd2aa14 142
daniQQue 42:7164ccd2aa14 143 wait(0.5f);
daniQQue 42:7164ccd2aa14 144
daniQQue 42:7164ccd2aa14 145 if (motorswitch%2==0)
daniQQue 42:7164ccd2aa14 146 {green=0;
daniQQue 42:7164ccd2aa14 147 red=1;}
daniQQue 42:7164ccd2aa14 148
daniQQue 42:7164ccd2aa14 149 else {green=1;
daniQQue 42:7164ccd2aa14 150 red=0;}
daniQQue 42:7164ccd2aa14 151
daniQQue 42:7164ccd2aa14 152 }
daniQQue 42:7164ccd2aa14 153
daniQQue 42:7164ccd2aa14 154 void calibration_triceps(){
daniQQue 42:7164ccd2aa14 155 red=1;
daniQQue 42:7164ccd2aa14 156 green=1;
daniQQue 42:7164ccd2aa14 157 blue=0;
daniQQue 42:7164ccd2aa14 158
daniQQue 42:7164ccd2aa14 159 pc.printf("start of calibration triceps\r\n");
daniQQue 42:7164ccd2aa14 160
daniQQue 42:7164ccd2aa14 161 for(int n =0; n<3000;n++) //read for 2000 samples as calibration
daniQQue 42:7164ccd2aa14 162 {
daniQQue 42:7164ccd2aa14 163 emg_triceps_right=emg_triceps_right_in.read(); //read the emg value from the elektrodes
daniQQue 42:7164ccd2aa14 164 emg_filtered_high_triceps_right= filterhigh_t1.step(emg_triceps_right);
daniQQue 42:7164ccd2aa14 165 emg_filtered_high_notch_1_triceps_right=filternotch1_t1.step(emg_filtered_high_triceps_right);
daniQQue 42:7164ccd2aa14 166 emg_abs_triceps_right=fabs(emg_filtered_high_notch_1_triceps_right); //fabs because float
daniQQue 42:7164ccd2aa14 167 emg_filtered_triceps_right=filterlow_t1.step(emg_abs_triceps_right);
daniQQue 42:7164ccd2aa14 168
daniQQue 42:7164ccd2aa14 169 if (emg_filtered_triceps_right > max_triceps) //determine what the highest reachable emg signal is
daniQQue 42:7164ccd2aa14 170 {
daniQQue 42:7164ccd2aa14 171 max_triceps = emg_filtered_triceps_right;
daniQQue 42:7164ccd2aa14 172
daniQQue 42:7164ccd2aa14 173 }
daniQQue 42:7164ccd2aa14 174 wait(0.001f); //to sample at same freq; 1000Hz
daniQQue 42:7164ccd2aa14 175 }
daniQQue 42:7164ccd2aa14 176 cut_off_value_triceps=percentage_max_triceps*max_triceps;
daniQQue 42:7164ccd2aa14 177 pc.printf(" end of calibration\r\n");
daniQQue 42:7164ccd2aa14 178 pc.printf(" change of cv triceps: %f ",cut_off_value_triceps );
daniQQue 42:7164ccd2aa14 179 blue=!blue;
daniQQue 42:7164ccd2aa14 180 wait(0.5f);
daniQQue 42:7164ccd2aa14 181 if (motorswitch%2==0)
daniQQue 42:7164ccd2aa14 182 {green=0;
daniQQue 42:7164ccd2aa14 183 red=1;}
daniQQue 42:7164ccd2aa14 184
daniQQue 42:7164ccd2aa14 185 else {green=1;
daniQQue 42:7164ccd2aa14 186 red=0;}
daniQQue 42:7164ccd2aa14 187
daniQQue 42:7164ccd2aa14 188 }
daniQQue 42:7164ccd2aa14 189
daniQQue 0:34c739fcc3e0 190 void filter(){
daniQQue 40:187ef29de53d 191 //biceps right arm read+filtering
daniQQue 15:bb4a6c7836d8 192 emg_biceps_right=emg_biceps_right_in.read(); //read the emg value from the elektrodes
daniQQue 40:187ef29de53d 193 emg_filtered_high_biceps_right= filterhigh_b1.step(emg_biceps_right);
daniQQue 40:187ef29de53d 194 emg_filtered_high_notch_1_biceps_right=filternotch1_b1.step(emg_filtered_high_biceps_right);
daniQQue 42:7164ccd2aa14 195 emg_abs_biceps_right=fabs(emg_filtered_high_notch_1_biceps_right); //fabs because float
daniQQue 40:187ef29de53d 196 emg_filtered_biceps_right=filterlow_b1.step(emg_abs_biceps_right);
daniQQue 40:187ef29de53d 197
daniQQue 40:187ef29de53d 198 //triceps right arm read+filtering
daniQQue 40:187ef29de53d 199 emg_triceps_right=emg_triceps_right_in.read(); //read the emg value from the elektrodes
daniQQue 40:187ef29de53d 200 emg_filtered_high_triceps_right= filterhigh_t1.step(emg_triceps_right);
daniQQue 40:187ef29de53d 201 emg_filtered_high_notch_1_triceps_right=filternotch1_t1.step(emg_filtered_high_triceps_right);
daniQQue 40:187ef29de53d 202 emg_abs_triceps_right=fabs(emg_filtered_high_notch_1_triceps_right); //fabs because float
daniQQue 40:187ef29de53d 203 emg_filtered_triceps_right=filterlow_t1.step(emg_abs_triceps_right);
daniQQue 7:42d0e38196f1 204
daniQQue 40:187ef29de53d 205 //biceps left arm read+filtering
daniQQue 40:187ef29de53d 206 emg_biceps_left=emg_biceps_left_in.read(); //read the emg value from the elektrodes
daniQQue 40:187ef29de53d 207 emg_filtered_high_biceps_left= filterhigh_b2.step(emg_biceps_left);
daniQQue 40:187ef29de53d 208 emg_filtered_high_notch_1_biceps_left=filternotch1_b2.step(emg_filtered_high_biceps_left);
daniQQue 40:187ef29de53d 209 emg_abs_biceps_left=fabs(emg_filtered_high_notch_1_biceps_left); //fabs because float
daniQQue 40:187ef29de53d 210 emg_filtered_biceps_left=filterlow_b2.step(emg_abs_biceps_left);
daniQQue 40:187ef29de53d 211
daniQQue 41:9ea3d5921f07 212 //signal substraction of filter biceps and triceps. right Biceps + left biceps -
daniQQue 41:9ea3d5921f07 213 signal_biceps_sum=emg_filtered_biceps_right-emg_filtered_biceps_left;
daniQQue 40:187ef29de53d 214
daniQQue 40:187ef29de53d 215 //creating of on/off signal with the created on/off signals, with if statement for right arm!
daniQQue 41:9ea3d5921f07 216 if (signal_biceps_sum>cut_off_value_biceps_right)
daniQQue 41:9ea3d5921f07 217 {onoffsignal_biceps=1;}
daniQQue 7:42d0e38196f1 218
daniQQue 41:9ea3d5921f07 219 else if (signal_biceps_sum<cut_off_value_biceps_left)
daniQQue 40:187ef29de53d 220 {
daniQQue 41:9ea3d5921f07 221 onoffsignal_biceps=-1;
daniQQue 40:187ef29de53d 222 }
daniQQue 40:187ef29de53d 223
daniQQue 40:187ef29de53d 224 else
daniQQue 41:9ea3d5921f07 225 {onoffsignal_biceps=0;}
daniQQue 7:42d0e38196f1 226
daniQQue 40:187ef29de53d 227 //creating on/off signal for switch (left arm)
daniQQue 40:187ef29de53d 228
daniQQue 41:9ea3d5921f07 229 if (emg_filtered_triceps_right>cut_off_value_triceps)
daniQQue 40:187ef29de53d 230 {
daniQQue 41:9ea3d5921f07 231 switch_signal_triceps=1;
daniQQue 40:187ef29de53d 232 }
daniQQue 40:187ef29de53d 233
daniQQue 40:187ef29de53d 234 else
daniQQue 40:187ef29de53d 235 {
daniQQue 41:9ea3d5921f07 236 switch_signal_triceps=0;
daniQQue 40:187ef29de53d 237 }
daniQQue 40:187ef29de53d 238
daniQQue 0:34c739fcc3e0 239 //send signals to scope
daniQQue 40:187ef29de53d 240 scope.set(0, emg_filtered_biceps_right); //set emg signal to scope in channel 0
daniQQue 40:187ef29de53d 241 scope.set(1, emg_filtered_triceps_right); // set emg signal to scope in channel 1
daniQQue 40:187ef29de53d 242 scope.set(2, emg_filtered_biceps_left); // set emg signal to scope in channel 2
daniQQue 41:9ea3d5921f07 243
daniQQue 40:187ef29de53d 244
daniQQue 40:187ef29de53d 245 scope.send(); //send all the signals to the scope
daniQQue 0:34c739fcc3e0 246 }
daniQQue 0:34c739fcc3e0 247
daniQQue 0:34c739fcc3e0 248 //program
daniQQue 0:34c739fcc3e0 249
daniQQue 0:34c739fcc3e0 250 int main()
daniQQue 0:34c739fcc3e0 251 {
daniQQue 42:7164ccd2aa14 252 pc.baud(115200); //connect with pc with baudrate 115200
daniQQue 42:7164ccd2aa14 253
daniQQue 42:7164ccd2aa14 254 sample_timer.attach(&filter, 0.001); //continously execute the EMG reader and filter, it ensures that filter and sampling is executed every 1/frequency seconds
daniQQue 42:7164ccd2aa14 255 switch_function.attach(&SwitchN,1.0); //switch is every second available
daniQQue 42:7164ccd2aa14 256 button_calibration_biceps.fall (&calibration_biceps); //to call calibration biceps, stop everything else
daniQQue 42:7164ccd2aa14 257 button_calibration_triceps.fall(&calibration_triceps); //to call calibration triceps, stop everything else
daniQQue 40:187ef29de53d 258
daniQQue 42:7164ccd2aa14 259 if (motorswitch%2==0)
daniQQue 42:7164ccd2aa14 260 { pc.printf("If you contract the right arm, the robot will go right \r\n");
daniQQue 42:7164ccd2aa14 261 pc.printf("If you contract biceps of the left arm, the robot will go left \r\n");
daniQQue 42:7164ccd2aa14 262 pc.printf("\r\n");
daniQQue 42:7164ccd2aa14 263 green=0;
daniQQue 42:7164ccd2aa14 264 red=1;
daniQQue 42:7164ccd2aa14 265 blue=1;
daniQQue 42:7164ccd2aa14 266 }
daniQQue 42:7164ccd2aa14 267
daniQQue 42:7164ccd2aa14 268 else
daniQQue 42:7164ccd2aa14 269 {pc.printf("If you contract the biceps of right arm, the robot will go up \r\n");
daniQQue 42:7164ccd2aa14 270 pc.printf("If you contract the biceps of left arm, the robot will go down \r\n");
daniQQue 42:7164ccd2aa14 271 pc.printf("\r\n");
daniQQue 42:7164ccd2aa14 272 green=1;
daniQQue 42:7164ccd2aa14 273 red=0;
daniQQue 42:7164ccd2aa14 274 blue=1;
daniQQue 42:7164ccd2aa14 275
daniQQue 42:7164ccd2aa14 276 }
daniQQue 0:34c739fcc3e0 277 //endless loop
daniQQue 0:34c739fcc3e0 278
daniQQue 40:187ef29de53d 279
daniQQue 40:187ef29de53d 280 while (true) { // zorgt er voor dat de code oneindig doorgelopen wordt
daniQQue 40:187ef29de53d 281
daniQQue 8:cd0cb71b69f2 282
daniQQue 41:9ea3d5921f07 283 if (onoffsignal_biceps==-1) // als s ingedrukt wordt gebeurd het volgende
daniQQue 40:187ef29de53d 284 {
daniQQue 42:7164ccd2aa14 285 if (motorswitch%2==0) // als s ingedrukt wordt en het getal is even gebeurd het onderstaande
daniQQue 40:187ef29de53d 286 {
daniQQue 40:187ef29de53d 287 richting_motor1 = 1;
daniQQue 40:187ef29de53d 288 pwm_motor1 = 1;
daniQQue 42:7164ccd2aa14 289
daniQQue 42:7164ccd2aa14 290
daniQQue 40:187ef29de53d 291
daniQQue 40:187ef29de53d 292 }
daniQQue 40:187ef29de53d 293
daniQQue 40:187ef29de53d 294 else // als s is ingedrukt maar het getal is niet even (dus oneven) gebeurdt het onderstaande
daniQQue 40:187ef29de53d 295 {
daniQQue 40:187ef29de53d 296 richting_motor2 = 1;
daniQQue 40:187ef29de53d 297 pwm_motor2 = 1;
daniQQue 42:7164ccd2aa14 298
daniQQue 40:187ef29de53d 299 }
daniQQue 40:187ef29de53d 300
daniQQue 8:cd0cb71b69f2 301 }
daniQQue 41:9ea3d5921f07 302 else if (onoffsignal_biceps==1) // als d ingedrukt wordt gebeurd het volgende
daniQQue 40:187ef29de53d 303 {
daniQQue 42:7164ccd2aa14 304 if (motorswitch%2==0) // als d is ingedrukt en n is even dan gebeurd het volgende
daniQQue 40:187ef29de53d 305 {
daniQQue 40:187ef29de53d 306 richting_motor1 = 0;
daniQQue 40:187ef29de53d 307 pwm_motor1 = 1;
daniQQue 40:187ef29de53d 308
daniQQue 42:7164ccd2aa14 309
daniQQue 40:187ef29de53d 310 }
daniQQue 40:187ef29de53d 311 else // als d is ingedrukt maar het getal is niet even (dus oneven) gebeurt het onderstaande
daniQQue 40:187ef29de53d 312 {
daniQQue 40:187ef29de53d 313 richting_motor2 = 0;
daniQQue 40:187ef29de53d 314 pwm_motor2 = 1;
daniQQue 42:7164ccd2aa14 315
daniQQue 40:187ef29de53d 316
daniQQue 40:187ef29de53d 317 }
daniQQue 40:187ef29de53d 318 }
daniQQue 40:187ef29de53d 319 else{
daniQQue 40:187ef29de53d 320
daniQQue 40:187ef29de53d 321 pwm_motor2=0;
daniQQue 40:187ef29de53d 322 pwm_motor1=0;
daniQQue 40:187ef29de53d 323 }
daniQQue 40:187ef29de53d 324
daniQQue 40:187ef29de53d 325 }
daniQQue 0:34c739fcc3e0 326
daniQQue 0:34c739fcc3e0 327 }