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
Diff: Project_main.cpp
- Revision:
- 37:2d248e64b745
- Parent:
- 36:af949aaaba01
- Child:
- 38:277ba1c0693c
diff -r af949aaaba01 -r 2d248e64b745 Project_main.cpp
--- a/Project_main.cpp Tue Oct 07 13:39:45 2014 +0000
+++ b/Project_main.cpp Tue Oct 07 14:01:51 2014 +0000
@@ -69,20 +69,24 @@
log_timer.attach(looper, 0.001); // The looper() function will be called every 0.001 seconds (with the ticker object)
// reset_timer.attach(resetlooper, 0.1); //
- while(1) { //Loop
+ goto directionchoice; // goes to first while(1) for the deciding the direction
+
+ while(1) { //Loop keuze DIRECTION
+directionchoice:
for(int i=1; i<4; i++) {
if(i==1) { //red
red=0;
green=1;
blue=1;
- for (int lag=0; lag<50; lag++) {
- if(emg_bifloat.read()>0.8) { // 0.8 klopt niet als grenswaarde. #nofilter
+ for (int lag=0; lag<TIMEBETWEENBLINK; lag++) {
+ if(emg_bifloat.read()>0.8) { // 0.8 klopt niet als grenswaarde. #nofilter
direction = 1;
+ red=1;
+ green = 0;
blue = 0;
- green = 0;
- red=1;
- wait(2); // Tijdelijke wait om oranje lampje aan te zetten ter controle selectie
- goto forcechoice;
+ pc.printf("links ");
+ wait(TIMEB4NEXTCHOICE); // Tijdelijke wait om cyaan lampje aan te zetten ter controle selectie
+ goto forcechoice; // goes to second while(1) for the deciding the force
} else {
wait(0.1);
}
@@ -92,13 +96,14 @@
red =1;
green=0;
blue=1;
- for (int lag=0; lag<50; lag++) {
+ for (int lag=0; lag<TIMEBETWEENBLINK; lag++) {
if(emg_bifloat.read()>0.8) { //0.8 klopt niet als grenswaarde. #nofilter
direction = 2;
- blue = 0;
+ red=0;
green = 1;
- red=0;
- wait(2); // Tijdelijke wait om oranje lampje aan te zetten ter controle selectie
+ blue = 0;
+ pc.printf("mid ");
+ wait(TIMEB4NEXTCHOICE); // Tijdelijke wait om paars lampje aan te zetten ter controle selectie
goto forcechoice;
} else {
wait(0.1);
@@ -109,13 +114,14 @@
red=1;
green=1;
blue=0;
- for (int lag=0; lag<50; lag++) {
+ for (int lag=0; lag<TIMEBETWEENBLINK; lag++) {
if(emg_bifloat.read()>0.8) { //0.8 klopt niet als grenswaarde. #nofilter
direction = 3;
- blue = 1;
+ red=0;
green = 0;
- red=0;
- wait(2); // Tijdelijke wait om oranje lampje aan te zetten ter controle selectie
+ blue = 1;
+ pc.printf("rechts ");
+ wait(TIMEB4NEXTCHOICE); // Tijdelijke wait om oranje lampje aan te zetten ter controle selectie
goto forcechoice;
} else {
wait(0.1);
@@ -123,149 +129,79 @@
}
}
}
-
}
+ while(1) { //Loop keuze FORCE
forcechoice:
- red = 0;
- green = 0;
- blue = 0;
- wait(5);
-
-
- /*
- goto directionchoice; // goes to first while(1) for the deciding the direction
-
- while(1) { //Loop keuze DIRECTION
- directionchoice:
- for(int i=1; i<4; i++) {
- if(i==1) { //red
- red=0;
- green=1;
- blue=1;
- for (int lag=0; lag<TIMEBETWEENBLINK; lag++) {
- if(emg_bifloat.read()>0.8) { // 0.8 klopt niet als grenswaarde. #nofilter
- direction = 1;
- red=1;
- green = 0;
- blue = 0;
- pc.printf("links ");
- wait(TIMEB4NEXTCHOICE); // Tijdelijke wait om cyaan lampje aan te zetten ter controle selectie
- goto forcechoice; // goes to second while(1) for the deciding the force
- } else {
- wait(0.1);
- }
+ for(int j=1; j<4; j++) {
+ if(j==1) { //red
+ red=0;
+ green=1;
+ blue=1;
+ if(direction==0) { //if statement die controleert of direction 0 is (dus of triceps gereset is)
+ goto directionchoice;
+ }
+ for (int lag=0; lag<TIMEBETWEENBLINK; lag++) {
+ if(emg_bifloat.read()>0.8) { // 0.8 klopt niet als grenswaarde. #nofilter
+ force = 1;
+ red=1;
+ green = 0;
+ blue = 0;
+ pc.printf("zwak ");
+ wait(TIMEB4NEXTCHOICE); // Tijdelijke wait om cyaan lampje aan te zetten ter controle selectie
+ goto choicesmade;
+ } else {
+ wait(0.1);
}
}
- if(i==2) { //green
- red =1;
- green=0;
- blue=1;
- for (int lag=0; lag<TIMEBETWEENBLINK; lag++) {
- if(emg_bifloat.read()>0.8) { //0.8 klopt niet als grenswaarde. #nofilter
- direction = 2;
- red=0;
- green = 1;
- blue = 0;
- pc.printf("mid ");
- wait(TIMEB4NEXTCHOICE); // Tijdelijke wait om paars lampje aan te zetten ter controle selectie
- goto forcechoice;
- } else {
- wait(0.1);
- }
+ }
+ if(j==2) { //green
+ red =1;
+ green=0;
+ blue=1;
+ if(direction==0) { //if statement die controleert of direction 0 is (dus of triceps gereset is)
+ goto directionchoice;
+ }
+ for (int lag=0; lag<TIMEBETWEENBLINK; lag++) {
+ if(emg_bifloat.read()>0.8) { //0.8 klopt niet als grenswaarde. #nofilter
+ force = 2;
+ red=0;
+ green = 1;
+ blue = 0;
+ pc.printf("normaal ");
+ wait(TIMEB4NEXTCHOICE); // Tijdelijke wait om paars lampje aan te zetten ter controle selectie
+ goto choicesmade;
+ } else {
+ wait(0.1);
}
}
- if(i==3) { //blue
- red=1;
- green=1;
- blue=0;
- for (int lag=0; lag<TIMEBETWEENBLINK; lag++) {
- if(emg_bifloat.read()>0.8) { //0.8 klopt niet als grenswaarde. #nofilter
- direction = 3;
- red=0;
- green = 0;
- blue = 1;
- pc.printf("rechts ");
- wait(TIMEB4NEXTCHOICE); // Tijdelijke wait om oranje lampje aan te zetten ter controle selectie
- goto forcechoice;
- } else {
- wait(0.1);
- }
+ }
+ if(j==3) { //blue
+ red=1;
+ green=1;
+ blue=0;
+ if(direction==0) { //if statement die controleert of direction 0 is (dus of triceps gereset is)
+ goto directionchoice;
+ }
+ for (int lag=0; lag<TIMEBETWEENBLINK; lag++) {
+ if(emg_bifloat.read()>0.8) { //0.8 klopt niet als grenswaarde. #nofilter
+ force = 3;
+ red=0;
+ green = 0;
+ blue = 1;
+ pc.printf("sterk ");
+ wait(TIMEB4NEXTCHOICE); // Tijdelijke wait om oranje lampje aan te zetten ter controle selectie
+ goto choicesmade;
+ } else {
+ wait(0.1);
}
}
}
}
- while(1) { //Loop keuze FORCE
- forcechoice:
- for(int j=1; j<4; j++) {
- if(j==1) { //red
- red=0;
- green=1;
- blue=1;
- if(direction==0){ //if statement die controleert of direction 0 is (dus of triceps gereset is)
- goto directionchoice;
- }
- for (int lag=0; lag<TIMEBETWEENBLINK; lag++) {
- if(emg_bifloat.read()>0.8) { // 0.8 klopt niet als grenswaarde. #nofilter
- force = 1;
- red=1;
- green = 0;
- blue = 0;
- pc.printf("zwak ");
- wait(TIMEB4NEXTCHOICE); // Tijdelijke wait om cyaan lampje aan te zetten ter controle selectie
- goto choicesmade;
- } else {
- wait(0.1);
- }
- }
- }
- if(j==2) { //green
- red =1;
- green=0;
- blue=1;
- if(direction==0){ //if statement die controleert of direction 0 is (dus of triceps gereset is)
- goto directionchoice;
- }
- for (int lag=0; lag<TIMEBETWEENBLINK; lag++) {
- if(emg_bifloat.read()>0.8) { //0.8 klopt niet als grenswaarde. #nofilter
- force = 2;
- red=0;
- green = 1;
- blue = 0;
- pc.printf("normaal ");
- wait(TIMEB4NEXTCHOICE); // Tijdelijke wait om paars lampje aan te zetten ter controle selectie
- goto choicesmade;
- } else {
- wait(0.1);
- }
- }
- }
- if(j==3) { //blue
- red=1;
- green=1;
- blue=0;
- if(direction==0){ //if statement die controleert of direction 0 is (dus of triceps gereset is)
- goto directionchoice;
- }
- for (int lag=0; lag<TIMEBETWEENBLINK; lag++) {
- if(emg_bifloat.read()>0.8) { //0.8 klopt niet als grenswaarde. #nofilter
- force = 3;
- red=0;
- green = 0;
- blue = 1;
- pc.printf("sterk ");
- wait(TIMEB4NEXTCHOICE); // Tijdelijke wait om oranje lampje aan te zetten ter controle selectie
- goto choicesmade;
- } else {
- wait(0.1);
- }
- }
- }
- }
- }
- choicesmade:
+ }
+choicesmade:
- /* Vanaf hier komt de aansturing van de motor (inclusief de controller)*/
- /*
+ /* Vanaf hier komt de aansturing van de motor (inclusief de controller)*/
+
if(direction == 1 && force == 1) { // links zwak
pc.printf("links zwak");
@@ -301,5 +237,5 @@
red = 0;
green = 0;
- blue = 0; // wit lampje */
+ blue = 0; // wit lampje
}
\ No newline at end of file