script zover
Dependencies: HIDScope MODSERIAL mbed
Diff: main.cpp
- Revision:
- 15:2adb036a191f
- Parent:
- 14:4c33f6240118
- Child:
- 16:f7881b420c83
diff -r 4c33f6240118 -r 2adb036a191f main.cpp --- a/main.cpp Wed Oct 22 12:51:15 2014 +0000 +++ b/main.cpp Wed Oct 22 13:28:24 2014 +0000 @@ -21,10 +21,13 @@ #define TSAMP 0.001 +#define TRESHOLD 0.03 + + AnalogIn emg1(PTB1); AnalogIn emg2(PTB2); -DigitalOut red(LED1); +DigitalOut red(LED1) ; DigitalOut blue(LED2); MODSERIAL pc(USBTX,USBRX); @@ -39,6 +42,7 @@ float ysum2 = 0, yave2=0 ; int set; +int y1, y2; float readEMG1() { @@ -150,8 +154,8 @@ ysum1 = ysum1+ylp1; n++; - if(n==100) { - yave1 = ysum1/100; + if(n==200) { + yave1 = ysum1/200; ysum1 = 0; n = 0; } @@ -182,15 +186,36 @@ timer.attach(setlooptimerflag,TSAMP); while(1) { - while(!looptimerflag); + looptimerflag = false; + emg_value1 = readEMG1(); emg_value2 = readEMG2(); - yave1 = filter1(emg_value1); + //yave1 = filter1(emg_value1); yave2 = filter2(emg_value2); - - + yave1 = 0.06; + if(yave1>TRESHOLD){ + y1 = 1; + blue = 1; + red =0; + } + else{ + y1 = 0; + red =0; + blue =1; + } + if(yave2>TRESHOLD){ + y2 = 1; + + } + else{ + y2 = 0; + } + + + + viewer(); } } \ No newline at end of file