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: HIDScope MODSERIAL- mbed-dsp mbed
Project_main.cpp@36:af949aaaba01, 2014-10-07 (annotated)
- Committer:
- Hooglugt
- Date:
- Tue Oct 07 13:39:45 2014 +0000
- Revision:
- 36:af949aaaba01
- Parent:
- 35:c3182df00ec8
- Child:
- 37:2d248e64b745
alle code in main groen gemaakt en oude wbuysman script ingezet
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Hooglugt | 23:8d9a623dd713 | 1 | #include "mbed.h" |
| Hooglugt | 23:8d9a623dd713 | 2 | #include "MODSERIAL.h" |
| Hooglugt | 23:8d9a623dd713 | 3 | #include "HIDScope.h" |
| Hooglugt | 29:7523e4a8e000 | 4 | |
| Hooglugt | 36:af949aaaba01 | 5 | #define TIMEB4NEXTCHOICE 5 // 1s keuzelampje blijft aan |
| Hooglugt | 36:af949aaaba01 | 6 | #define TIMEBETWEENBLINK 50 // 1s voor volgende blink |
| Hooglugt | 23:8d9a623dd713 | 7 | |
| Hooglugt | 23:8d9a623dd713 | 8 | //Define objects |
| Hooglugt | 29:7523e4a8e000 | 9 | AnalogIn emg0(PTB1); //Analog input biceps |
| Hooglugt | 29:7523e4a8e000 | 10 | AnalogIn emg1(PTB2); //Analog input triceps |
| Hooglugt | 29:7523e4a8e000 | 11 | |
| Hooglugt | 32:aaf01b1bf05d | 12 | PwmOut emg_bifloat(PTD4); //Float voor EMG-waarde biceps, VRAAG: waarom we hier een PwmOut voor gebruiken - kunnen we geen float gebruiken? |
| Hooglugt | 29:7523e4a8e000 | 13 | PwmOut emg_trifloat(PTA4); //Float voor EMG-waarde triceps |
| Hooglugt | 29:7523e4a8e000 | 14 | |
| Hooglugt | 29:7523e4a8e000 | 15 | PwmOut red(LED_RED); |
| Hooglugt | 23:8d9a623dd713 | 16 | PwmOut green(LED_GREEN); |
| Hooglugt | 23:8d9a623dd713 | 17 | PwmOut blue(LED_BLUE); |
| Hooglugt | 29:7523e4a8e000 | 18 | |
| Hooglugt | 35:c3182df00ec8 | 19 | int direction = 0; |
| Hooglugt | 35:c3182df00ec8 | 20 | int force = 0; |
| Hooglugt | 23:8d9a623dd713 | 21 | |
| Hooglugt | 23:8d9a623dd713 | 22 | Ticker log_timer; |
| Hooglugt | 30:5e5098b0cca6 | 23 | Ticker reset_timer; |
| Hooglugt | 23:8d9a623dd713 | 24 | MODSERIAL pc(USBTX,USBRX); |
| Hooglugt | 29:7523e4a8e000 | 25 | HIDScope scope(4); |
| Hooglugt | 23:8d9a623dd713 | 26 | |
| Hooglugt | 29:7523e4a8e000 | 27 | void looper() //nieuwe looper maken, die om een nog te bepalen tijdseenheid de emgtrifloat checked en anders nieuwe goto maakt naar vorige selectiekeuze |
| Hooglugt | 23:8d9a623dd713 | 28 | { |
| Hooglugt | 29:7523e4a8e000 | 29 | /*put raw emg value of biceps both in emg_bifloat and in emg_bivalue*/ |
| Hooglugt | 29:7523e4a8e000 | 30 | emg_bifloat.write(emg0.read()); // read float value (0..1 = 0..3.3V) biceps |
| Hooglugt | 29:7523e4a8e000 | 31 | uint16_t emg_bivalue; |
| Hooglugt | 29:7523e4a8e000 | 32 | emg_bivalue = emg0.read_u16(); // read direct ADC result (0..4096 = 0..3.3V) biceps |
| Hooglugt | 29:7523e4a8e000 | 33 | |
| Hooglugt | 29:7523e4a8e000 | 34 | /*put raw emg value of triceps both in emg_trifloat and in emg_trivalue*/ |
| Hooglugt | 29:7523e4a8e000 | 35 | emg_trifloat.write(emg1.read()); // read float value (0..1 = 0..3.3V) triiceps |
| Hooglugt | 29:7523e4a8e000 | 36 | uint16_t emg_trivalue; |
| Hooglugt | 29:7523e4a8e000 | 37 | emg_trivalue = emg1.read_u16(); // read direct ADC result (0..4096 = 0..3.3V) biceps |
| Hooglugt | 29:7523e4a8e000 | 38 | |
| Hooglugt | 31:d8eaf0ce8517 | 39 | /*send value to PC. Line below is used to prevent buffer overrun */ |
| Hooglugt | 30:5e5098b0cca6 | 40 | if(pc.rxBufferGetSize(0)-pc.rxBufferGetCount() > 30) { //VRAAG: praktisch nut hiervan? print emg value wanneer buffercount groter dan 30 is |
| Hooglugt | 30:5e5098b0cca6 | 41 | //pc.printf("%u\n",emg_bivalue); |
| Hooglugt | 29:7523e4a8e000 | 42 | } |
| Hooglugt | 36:af949aaaba01 | 43 | |
| Hooglugt | 34:e166187e62ce | 44 | /* EMG-singaal van biceps en triceps worden hier gefilterd*/ |
| Hooglugt | 36:af949aaaba01 | 45 | |
| Hooglugt | 29:7523e4a8e000 | 46 | scope.set(0,emg_bivalue); |
| Hooglugt | 29:7523e4a8e000 | 47 | scope.set(1,emg_bifloat.read()); |
| Hooglugt | 29:7523e4a8e000 | 48 | scope.set(2,emg_trivalue); |
| Hooglugt | 29:7523e4a8e000 | 49 | scope.set(3,emg_trifloat.read()); |
| Hooglugt | 23:8d9a623dd713 | 50 | scope.send(); |
| Hooglugt | 23:8d9a623dd713 | 51 | } |
| Hooglugt | 23:8d9a623dd713 | 52 | |
| Hooglugt | 34:e166187e62ce | 53 | /* |
| Hooglugt | 32:aaf01b1bf05d | 54 | void resetlooper() // VRAAG: wat gebeurt er wanneer en resetlooper en looper tegelijkertijd gecalled worden?! |
| Hooglugt | 31:d8eaf0ce8517 | 55 | { |
| Hooglugt | 30:5e5098b0cca6 | 56 | if(emg_trifloat.read()>0.8 && direction != 0) { //dit is alleen mogelijk wanneer directionchoice is gemaakt |
| Hooglugt | 30:5e5098b0cca6 | 57 | direction = 0; |
| Hooglugt | 30:5e5098b0cca6 | 58 | force = 0; // WEGHALEN, wanneer in uiteindelijke script na force keuzen niet meer gereset kan worden (voor nu wel handig) |
| Hooglugt | 31:d8eaf0ce8517 | 59 | pc.printf("reset "); |
| Hooglugt | 31:d8eaf0ce8517 | 60 | } |
| Hooglugt | 30:5e5098b0cca6 | 61 | } |
| Hooglugt | 35:c3182df00ec8 | 62 | CONSTANTE RESETS DOOR BEWEGINGSARTEFACTEN */ |
| Hooglugt | 31:d8eaf0ce8517 | 63 | |
| Hooglugt | 23:8d9a623dd713 | 64 | int main() |
| Hooglugt | 23:8d9a623dd713 | 65 | { |
| Hooglugt | 25:ec41b972b250 | 66 | pc.baud(115200); //baudrate instellen |
| Hooglugt | 29:7523e4a8e000 | 67 | emg_bifloat.period_ms(2); //sets period for the PWM to the emgfloat PTD4 |
| Hooglugt | 29:7523e4a8e000 | 68 | emg_trifloat.period_ms(2); |
| Hooglugt | 25:ec41b972b250 | 69 | log_timer.attach(looper, 0.001); // The looper() function will be called every 0.001 seconds (with the ticker object) |
| Hooglugt | 34:e166187e62ce | 70 | // reset_timer.attach(resetlooper, 0.1); // |
| Hooglugt | 32:aaf01b1bf05d | 71 | |
| Hooglugt | 36:af949aaaba01 | 72 | while(1) { //Loop |
| Hooglugt | 23:8d9a623dd713 | 73 | for(int i=1; i<4; i++) { |
| Hooglugt | 23:8d9a623dd713 | 74 | if(i==1) { //red |
| Hooglugt | 23:8d9a623dd713 | 75 | red=0; |
| Hooglugt | 23:8d9a623dd713 | 76 | green=1; |
| Hooglugt | 23:8d9a623dd713 | 77 | blue=1; |
| Hooglugt | 36:af949aaaba01 | 78 | for (int lag=0; lag<50; lag++) { |
| Hooglugt | 36:af949aaaba01 | 79 | if(emg_bifloat.read()>0.8) { // 0.8 klopt niet als grenswaarde. #nofilter |
| Hooglugt | 25:ec41b972b250 | 80 | direction = 1; |
| Hooglugt | 36:af949aaaba01 | 81 | blue = 0; |
| Hooglugt | 29:7523e4a8e000 | 82 | green = 0; |
| Hooglugt | 36:af949aaaba01 | 83 | red=1; |
| Hooglugt | 36:af949aaaba01 | 84 | wait(2); // Tijdelijke wait om oranje lampje aan te zetten ter controle selectie |
| Hooglugt | 36:af949aaaba01 | 85 | goto forcechoice; |
| Hooglugt | 23:8d9a623dd713 | 86 | } else { |
| Hooglugt | 23:8d9a623dd713 | 87 | wait(0.1); |
| Hooglugt | 23:8d9a623dd713 | 88 | } |
| Hooglugt | 23:8d9a623dd713 | 89 | } |
| Hooglugt | 23:8d9a623dd713 | 90 | } |
| Hooglugt | 23:8d9a623dd713 | 91 | if(i==2) { //green |
| Hooglugt | 23:8d9a623dd713 | 92 | red =1; |
| Hooglugt | 23:8d9a623dd713 | 93 | green=0; |
| Hooglugt | 23:8d9a623dd713 | 94 | blue=1; |
| Hooglugt | 36:af949aaaba01 | 95 | for (int lag=0; lag<50; lag++) { |
| Hooglugt | 29:7523e4a8e000 | 96 | if(emg_bifloat.read()>0.8) { //0.8 klopt niet als grenswaarde. #nofilter |
| Hooglugt | 25:ec41b972b250 | 97 | direction = 2; |
| Hooglugt | 36:af949aaaba01 | 98 | blue = 0; |
| Hooglugt | 29:7523e4a8e000 | 99 | green = 1; |
| Hooglugt | 36:af949aaaba01 | 100 | red=0; |
| Hooglugt | 36:af949aaaba01 | 101 | wait(2); // Tijdelijke wait om oranje lampje aan te zetten ter controle selectie |
| Hooglugt | 23:8d9a623dd713 | 102 | goto forcechoice; |
| Hooglugt | 23:8d9a623dd713 | 103 | } else { |
| Hooglugt | 23:8d9a623dd713 | 104 | wait(0.1); |
| Hooglugt | 23:8d9a623dd713 | 105 | } |
| Hooglugt | 23:8d9a623dd713 | 106 | } |
| Hooglugt | 23:8d9a623dd713 | 107 | } |
| Hooglugt | 23:8d9a623dd713 | 108 | if(i==3) { //blue |
| Hooglugt | 23:8d9a623dd713 | 109 | red=1; |
| Hooglugt | 23:8d9a623dd713 | 110 | green=1; |
| Hooglugt | 23:8d9a623dd713 | 111 | blue=0; |
| Hooglugt | 36:af949aaaba01 | 112 | for (int lag=0; lag<50; lag++) { |
| Hooglugt | 29:7523e4a8e000 | 113 | if(emg_bifloat.read()>0.8) { //0.8 klopt niet als grenswaarde. #nofilter |
| Hooglugt | 23:8d9a623dd713 | 114 | direction = 3; |
| Hooglugt | 36:af949aaaba01 | 115 | blue = 1; |
| Hooglugt | 29:7523e4a8e000 | 116 | green = 0; |
| Hooglugt | 36:af949aaaba01 | 117 | red=0; |
| Hooglugt | 36:af949aaaba01 | 118 | wait(2); // Tijdelijke wait om oranje lampje aan te zetten ter controle selectie |
| Hooglugt | 23:8d9a623dd713 | 119 | goto forcechoice; |
| Hooglugt | 23:8d9a623dd713 | 120 | } else { |
| Hooglugt | 23:8d9a623dd713 | 121 | wait(0.1); |
| Hooglugt | 23:8d9a623dd713 | 122 | } |
| Hooglugt | 23:8d9a623dd713 | 123 | } |
| Hooglugt | 23:8d9a623dd713 | 124 | } |
| Hooglugt | 25:ec41b972b250 | 125 | } |
| Hooglugt | 36:af949aaaba01 | 126 | |
| Hooglugt | 23:8d9a623dd713 | 127 | } |
| Hooglugt | 25:ec41b972b250 | 128 | forcechoice: |
| Hooglugt | 36:af949aaaba01 | 129 | red = 0; |
| Hooglugt | 36:af949aaaba01 | 130 | green = 0; |
| Hooglugt | 36:af949aaaba01 | 131 | blue = 0; |
| Hooglugt | 36:af949aaaba01 | 132 | wait(5); |
| Hooglugt | 36:af949aaaba01 | 133 | |
| Hooglugt | 36:af949aaaba01 | 134 | |
| Hooglugt | 36:af949aaaba01 | 135 | /* |
| Hooglugt | 36:af949aaaba01 | 136 | goto directionchoice; // goes to first while(1) for the deciding the direction |
| Hooglugt | 36:af949aaaba01 | 137 | |
| Hooglugt | 36:af949aaaba01 | 138 | while(1) { //Loop keuze DIRECTION |
| Hooglugt | 36:af949aaaba01 | 139 | directionchoice: |
| Hooglugt | 36:af949aaaba01 | 140 | for(int i=1; i<4; i++) { |
| Hooglugt | 36:af949aaaba01 | 141 | if(i==1) { //red |
| Hooglugt | 36:af949aaaba01 | 142 | red=0; |
| Hooglugt | 36:af949aaaba01 | 143 | green=1; |
| Hooglugt | 36:af949aaaba01 | 144 | blue=1; |
| Hooglugt | 36:af949aaaba01 | 145 | for (int lag=0; lag<TIMEBETWEENBLINK; lag++) { |
| Hooglugt | 36:af949aaaba01 | 146 | if(emg_bifloat.read()>0.8) { // 0.8 klopt niet als grenswaarde. #nofilter |
| Hooglugt | 36:af949aaaba01 | 147 | direction = 1; |
| Hooglugt | 36:af949aaaba01 | 148 | red=1; |
| Hooglugt | 36:af949aaaba01 | 149 | green = 0; |
| Hooglugt | 36:af949aaaba01 | 150 | blue = 0; |
| Hooglugt | 36:af949aaaba01 | 151 | pc.printf("links "); |
| Hooglugt | 36:af949aaaba01 | 152 | wait(TIMEB4NEXTCHOICE); // Tijdelijke wait om cyaan lampje aan te zetten ter controle selectie |
| Hooglugt | 36:af949aaaba01 | 153 | goto forcechoice; // goes to second while(1) for the deciding the force |
| Hooglugt | 36:af949aaaba01 | 154 | } else { |
| Hooglugt | 36:af949aaaba01 | 155 | wait(0.1); |
| Hooglugt | 36:af949aaaba01 | 156 | } |
| Hooglugt | 23:8d9a623dd713 | 157 | } |
| Hooglugt | 23:8d9a623dd713 | 158 | } |
| Hooglugt | 36:af949aaaba01 | 159 | if(i==2) { //green |
| Hooglugt | 36:af949aaaba01 | 160 | red =1; |
| Hooglugt | 36:af949aaaba01 | 161 | green=0; |
| Hooglugt | 36:af949aaaba01 | 162 | blue=1; |
| Hooglugt | 36:af949aaaba01 | 163 | for (int lag=0; lag<TIMEBETWEENBLINK; lag++) { |
| Hooglugt | 36:af949aaaba01 | 164 | if(emg_bifloat.read()>0.8) { //0.8 klopt niet als grenswaarde. #nofilter |
| Hooglugt | 36:af949aaaba01 | 165 | direction = 2; |
| Hooglugt | 36:af949aaaba01 | 166 | red=0; |
| Hooglugt | 36:af949aaaba01 | 167 | green = 1; |
| Hooglugt | 36:af949aaaba01 | 168 | blue = 0; |
| Hooglugt | 36:af949aaaba01 | 169 | pc.printf("mid "); |
| Hooglugt | 36:af949aaaba01 | 170 | wait(TIMEB4NEXTCHOICE); // Tijdelijke wait om paars lampje aan te zetten ter controle selectie |
| Hooglugt | 36:af949aaaba01 | 171 | goto forcechoice; |
| Hooglugt | 36:af949aaaba01 | 172 | } else { |
| Hooglugt | 36:af949aaaba01 | 173 | wait(0.1); |
| Hooglugt | 36:af949aaaba01 | 174 | } |
| Hooglugt | 23:8d9a623dd713 | 175 | } |
| Hooglugt | 23:8d9a623dd713 | 176 | } |
| Hooglugt | 36:af949aaaba01 | 177 | if(i==3) { //blue |
| Hooglugt | 36:af949aaaba01 | 178 | red=1; |
| Hooglugt | 36:af949aaaba01 | 179 | green=1; |
| Hooglugt | 36:af949aaaba01 | 180 | blue=0; |
| Hooglugt | 36:af949aaaba01 | 181 | for (int lag=0; lag<TIMEBETWEENBLINK; lag++) { |
| Hooglugt | 36:af949aaaba01 | 182 | if(emg_bifloat.read()>0.8) { //0.8 klopt niet als grenswaarde. #nofilter |
| Hooglugt | 36:af949aaaba01 | 183 | direction = 3; |
| Hooglugt | 36:af949aaaba01 | 184 | red=0; |
| Hooglugt | 36:af949aaaba01 | 185 | green = 0; |
| Hooglugt | 36:af949aaaba01 | 186 | blue = 1; |
| Hooglugt | 36:af949aaaba01 | 187 | pc.printf("rechts "); |
| Hooglugt | 36:af949aaaba01 | 188 | wait(TIMEB4NEXTCHOICE); // Tijdelijke wait om oranje lampje aan te zetten ter controle selectie |
| Hooglugt | 36:af949aaaba01 | 189 | goto forcechoice; |
| Hooglugt | 36:af949aaaba01 | 190 | } else { |
| Hooglugt | 36:af949aaaba01 | 191 | wait(0.1); |
| Hooglugt | 36:af949aaaba01 | 192 | } |
| Hooglugt | 23:8d9a623dd713 | 193 | } |
| Hooglugt | 23:8d9a623dd713 | 194 | } |
| Hooglugt | 23:8d9a623dd713 | 195 | } |
| Hooglugt | 23:8d9a623dd713 | 196 | } |
| Hooglugt | 36:af949aaaba01 | 197 | while(1) { //Loop keuze FORCE |
| Hooglugt | 36:af949aaaba01 | 198 | forcechoice: |
| Hooglugt | 36:af949aaaba01 | 199 | for(int j=1; j<4; j++) { |
| Hooglugt | 36:af949aaaba01 | 200 | if(j==1) { //red |
| Hooglugt | 36:af949aaaba01 | 201 | red=0; |
| Hooglugt | 36:af949aaaba01 | 202 | green=1; |
| Hooglugt | 36:af949aaaba01 | 203 | blue=1; |
| Hooglugt | 36:af949aaaba01 | 204 | if(direction==0){ //if statement die controleert of direction 0 is (dus of triceps gereset is) |
| Hooglugt | 36:af949aaaba01 | 205 | goto directionchoice; |
| Hooglugt | 36:af949aaaba01 | 206 | } |
| Hooglugt | 36:af949aaaba01 | 207 | for (int lag=0; lag<TIMEBETWEENBLINK; lag++) { |
| Hooglugt | 36:af949aaaba01 | 208 | if(emg_bifloat.read()>0.8) { // 0.8 klopt niet als grenswaarde. #nofilter |
| Hooglugt | 36:af949aaaba01 | 209 | force = 1; |
| Hooglugt | 36:af949aaaba01 | 210 | red=1; |
| Hooglugt | 36:af949aaaba01 | 211 | green = 0; |
| Hooglugt | 36:af949aaaba01 | 212 | blue = 0; |
| Hooglugt | 36:af949aaaba01 | 213 | pc.printf("zwak "); |
| Hooglugt | 36:af949aaaba01 | 214 | wait(TIMEB4NEXTCHOICE); // Tijdelijke wait om cyaan lampje aan te zetten ter controle selectie |
| Hooglugt | 36:af949aaaba01 | 215 | goto choicesmade; |
| Hooglugt | 36:af949aaaba01 | 216 | } else { |
| Hooglugt | 36:af949aaaba01 | 217 | wait(0.1); |
| Hooglugt | 36:af949aaaba01 | 218 | } |
| Hooglugt | 36:af949aaaba01 | 219 | } |
| Hooglugt | 36:af949aaaba01 | 220 | } |
| Hooglugt | 36:af949aaaba01 | 221 | if(j==2) { //green |
| Hooglugt | 36:af949aaaba01 | 222 | red =1; |
| Hooglugt | 36:af949aaaba01 | 223 | green=0; |
| Hooglugt | 36:af949aaaba01 | 224 | blue=1; |
| Hooglugt | 36:af949aaaba01 | 225 | if(direction==0){ //if statement die controleert of direction 0 is (dus of triceps gereset is) |
| Hooglugt | 36:af949aaaba01 | 226 | goto directionchoice; |
| Hooglugt | 36:af949aaaba01 | 227 | } |
| Hooglugt | 36:af949aaaba01 | 228 | for (int lag=0; lag<TIMEBETWEENBLINK; lag++) { |
| Hooglugt | 36:af949aaaba01 | 229 | if(emg_bifloat.read()>0.8) { //0.8 klopt niet als grenswaarde. #nofilter |
| Hooglugt | 36:af949aaaba01 | 230 | force = 2; |
| Hooglugt | 36:af949aaaba01 | 231 | red=0; |
| Hooglugt | 36:af949aaaba01 | 232 | green = 1; |
| Hooglugt | 36:af949aaaba01 | 233 | blue = 0; |
| Hooglugt | 36:af949aaaba01 | 234 | pc.printf("normaal "); |
| Hooglugt | 36:af949aaaba01 | 235 | wait(TIMEB4NEXTCHOICE); // Tijdelijke wait om paars lampje aan te zetten ter controle selectie |
| Hooglugt | 36:af949aaaba01 | 236 | goto choicesmade; |
| Hooglugt | 36:af949aaaba01 | 237 | } else { |
| Hooglugt | 36:af949aaaba01 | 238 | wait(0.1); |
| Hooglugt | 36:af949aaaba01 | 239 | } |
| Hooglugt | 36:af949aaaba01 | 240 | } |
| Hooglugt | 36:af949aaaba01 | 241 | } |
| Hooglugt | 36:af949aaaba01 | 242 | if(j==3) { //blue |
| Hooglugt | 36:af949aaaba01 | 243 | red=1; |
| Hooglugt | 36:af949aaaba01 | 244 | green=1; |
| Hooglugt | 36:af949aaaba01 | 245 | blue=0; |
| Hooglugt | 36:af949aaaba01 | 246 | if(direction==0){ //if statement die controleert of direction 0 is (dus of triceps gereset is) |
| Hooglugt | 36:af949aaaba01 | 247 | goto directionchoice; |
| Hooglugt | 36:af949aaaba01 | 248 | } |
| Hooglugt | 36:af949aaaba01 | 249 | for (int lag=0; lag<TIMEBETWEENBLINK; lag++) { |
| Hooglugt | 36:af949aaaba01 | 250 | if(emg_bifloat.read()>0.8) { //0.8 klopt niet als grenswaarde. #nofilter |
| Hooglugt | 36:af949aaaba01 | 251 | force = 3; |
| Hooglugt | 36:af949aaaba01 | 252 | red=0; |
| Hooglugt | 36:af949aaaba01 | 253 | green = 0; |
| Hooglugt | 36:af949aaaba01 | 254 | blue = 1; |
| Hooglugt | 36:af949aaaba01 | 255 | pc.printf("sterk "); |
| Hooglugt | 36:af949aaaba01 | 256 | wait(TIMEB4NEXTCHOICE); // Tijdelijke wait om oranje lampje aan te zetten ter controle selectie |
| Hooglugt | 36:af949aaaba01 | 257 | goto choicesmade; |
| Hooglugt | 36:af949aaaba01 | 258 | } else { |
| Hooglugt | 36:af949aaaba01 | 259 | wait(0.1); |
| Hooglugt | 36:af949aaaba01 | 260 | } |
| Hooglugt | 36:af949aaaba01 | 261 | } |
| Hooglugt | 36:af949aaaba01 | 262 | } |
| Hooglugt | 36:af949aaaba01 | 263 | } |
| Hooglugt | 36:af949aaaba01 | 264 | } |
| Hooglugt | 36:af949aaaba01 | 265 | choicesmade: |
| Hooglugt | 33:a78ec776dfd5 | 266 | |
| Hooglugt | 36:af949aaaba01 | 267 | /* Vanaf hier komt de aansturing van de motor (inclusief de controller)*/ |
| Hooglugt | 36:af949aaaba01 | 268 | /* |
| Hooglugt | 33:a78ec776dfd5 | 269 | |
| Hooglugt | 25:ec41b972b250 | 270 | if(direction == 1 && force == 1) { // links zwak |
| Hooglugt | 25:ec41b972b250 | 271 | pc.printf("links zwak"); |
| Hooglugt | 25:ec41b972b250 | 272 | } |
| Hooglugt | 25:ec41b972b250 | 273 | if(direction == 1 && force == 2) { // links normaal |
| Hooglugt | 25:ec41b972b250 | 274 | pc.printf("links normaal"); |
| Hooglugt | 25:ec41b972b250 | 275 | } |
| Hooglugt | 25:ec41b972b250 | 276 | if(direction == 1 && force == 3) { // links sterk |
| Hooglugt | 25:ec41b972b250 | 277 | pc.printf("links sterk"); |
| Hooglugt | 25:ec41b972b250 | 278 | } |
| Hooglugt | 25:ec41b972b250 | 279 | if(direction == 2 && force == 1) { // mid zwak |
| Hooglugt | 25:ec41b972b250 | 280 | pc.printf("mid zwak"); |
| Hooglugt | 25:ec41b972b250 | 281 | } |
| Hooglugt | 25:ec41b972b250 | 282 | if(direction == 2 && force == 2) { // mid normaal |
| Hooglugt | 25:ec41b972b250 | 283 | pc.printf("mid normaal"); |
| Hooglugt | 25:ec41b972b250 | 284 | } |
| Hooglugt | 25:ec41b972b250 | 285 | if(direction == 2 && force == 3) { // mid sterk |
| Hooglugt | 25:ec41b972b250 | 286 | pc.printf("mid sterk"); |
| Hooglugt | 25:ec41b972b250 | 287 | } |
| Hooglugt | 25:ec41b972b250 | 288 | if(direction == 3 && force == 1) { // rechts zwak |
| Hooglugt | 25:ec41b972b250 | 289 | pc.printf("rechts zwak"); |
| Hooglugt | 25:ec41b972b250 | 290 | } |
| Hooglugt | 25:ec41b972b250 | 291 | if(direction == 3 && force == 2) { // rechts normaal |
| Hooglugt | 25:ec41b972b250 | 292 | pc.printf("rechts normaal"); |
| Hooglugt | 25:ec41b972b250 | 293 | } |
| Hooglugt | 25:ec41b972b250 | 294 | if(direction == 3 && force == 3) { // rechts sterk |
| Hooglugt | 25:ec41b972b250 | 295 | pc.printf("rechts sterk"); |
| Hooglugt | 25:ec41b972b250 | 296 | } |
| Hooglugt | 33:a78ec776dfd5 | 297 | if(direction == 0 || force == 0) { // wanneer de triceps in de korte tijd is aangespannen nadat beide keuzes zijn gemaakt |
| Hooglugt | 32:aaf01b1bf05d | 298 | pc.printf("error"); |
| Hooglugt | 33:a78ec776dfd5 | 299 | // mogelijkheid om een goto te maken naar directionchoice (opzich wel handig) |
| Hooglugt | 32:aaf01b1bf05d | 300 | } |
| Hooglugt | 33:a78ec776dfd5 | 301 | |
| Hooglugt | 32:aaf01b1bf05d | 302 | red = 0; |
| Hooglugt | 32:aaf01b1bf05d | 303 | green = 0; |
| Hooglugt | 36:af949aaaba01 | 304 | blue = 0; // wit lampje */ |
| Hooglugt | 25:ec41b972b250 | 305 | } |