![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Code for emg filtering and thus controlling the robotic movement.
Dependencies: HIDScope biquadFilter mbed
Fork of EMG by
Diff: main.cpp
- Revision:
- 6:80c13d99aa55
- Parent:
- 5:4dacb7b72109
- Child:
- 7:3396c3e33928
--- a/main.cpp Wed Oct 02 09:45:01 2013 +0000 +++ b/main.cpp Thu Oct 03 13:47:49 2013 +0000 @@ -1,10 +1,11 @@ #include "mbed.h" +#include "MODSERIAL.h" //Define objects AnalogIn emg0(PTB0); //Analog input PwmOut red(LED_RED); //PWM output Ticker timer; -Serial pc(USBTX,USBRX); +MODSERIAL pc(USBTX,USBRX,64,1024); /** Looper function * functions used for Ticker and Timeout should be of type void <name>(void) @@ -26,7 +27,8 @@ /*put raw emg value both in red and in emg_value*/ red = emg_value = emg0.read(); /*send value to PC. use 6 digits after decimal sign*/ - pc.printf("%.6f\n",emg_value); + if(pc.rxBufferGetSize(0)-pc.rxBufferGetCount() > 30) + pc.printf("%.6f\n",emg_value); /**When not using the LED, the above could also have been done this way: * pc.printf("%.6\n", emg0.read()); */