EMG signalen uitlezen met filters

Dependencies:   HIDScope biquadFilter mbed

Revision:
0:5759df060d75
Child:
1:0d62559f43af
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Oct 27 10:59:47 2016 +0000
@@ -0,0 +1,40 @@
+#include "mbed.h"
+#include "HIDScope.h"
+
+
+//Define objects
+AnalogIn    emg0( A0 );
+AnalogIn    emg1( A1 );
+AnalogIn    emg2( A2 );
+
+Ticker      sample_timer;
+HIDScope    scope( 3 );     // Instantize a 3-channel HIDScope object
+DigitalOut  led(LED1);      // Instantize the timer for sending data to the PC 
+
+/** Sample function
+ * this function samples the emg and sends it to HIDScope
+ **/
+void sample()
+{
+    /* Set the sampled emg values in channel 0/1/2 (the first/second/third channel) in the 'HIDScope' instance named 'scope' */
+    scope.set(0, emg0.read() );
+    scope.set(1, emg1.read() );
+    scope.set(2, emg2.read() );
+    
+    
+    /*  Finally, send all channels to the PC at once */
+    scope.send();
+    /* To indicate that the function is working, the LED is toggled */
+    led = !led;
+}
+
+int main()
+{   
+    /**Attach the 'sample' function to the timer 'sample_timer'.
+    * this ensures that 'sample' is executed every... 0.001 seconds = 1000 Hz
+    */
+    sample_timer.attach(&sample, 0.001);
+
+    /*empty loop, sample() is executed periodically*/
+    while(1) {}
+}
\ No newline at end of file