emg including calibration, (pin values still has to be checked and determined what we want as the gain. this calibration is don over the all the muscles at once

Dependencies:   HIDScope mbed

Fork of Low_end_EMG_measuring by Casper Kroon

Revision:
1:1a38cc6622f6
Parent:
0:498fc20f5c30
--- a/main.cpp	Thu Sep 27 13:07:35 2018 +0000
+++ b/main.cpp	Thu Oct 18 09:37:39 2018 +0000
@@ -2,21 +2,24 @@
 #include "HIDScope.h"
 
 //Define objects
-AnalogIn    emg0( A0 );
-AnalogIn    emg1( A1 );
+AnalogIn    emg0( A0 );         //emg sensor A0
+AnalogIn    emg1( A1 );         //emg sensor A1
+AnalogIn    emg2( A2 );         //emg sensor A3
+DigitalIn button_emg(D4);       //button for emg calibration (pin must be ckecked if empty
 
 Ticker      sample_timer;
-HIDScope    scope( 4 );
+HIDScope    scope( 6 );         //6 channels in hidscope
 DigitalOut  led(LED1);
 
 /** Sample function
- * this function samples the emg and sends it to HIDScope
+ * this function_Samples the emg_and_Sends it to HIDScope_
  **/
 void sample()
 {
     /* Set the sampled emg values in channel 0 (the first channel) and 1 (the second channel) in the 'HIDScope' instance named 'scope' */
     scope.set(0, emg0.read() );
     scope.set(1, emg1.read() );
+    scope.set(2, emg2.read() );
 
     scope.send();
     /* To indicate that the function is working, the LED is toggled */
@@ -28,8 +31,21 @@
     /**Attach the 'sample' function to the timer 'sample_timer'.
     * this ensures that 'sample' is executed every... 0.002 seconds = 500 Hz
     */
+//______emg calibration______// 
+    while (button_emg == false) {
+        if (&sample >= 0,05) { 
+            &sample = &sample*2; 
+        }
+        else if (&sample >= 0,2) {
+            &sample = &sample;
+        }
+        else ($sample >= 0,5) {
+            &sample = &sample/2; 
+        }
+    }
+    while (button_emg == true) {
     sample_timer.attach(&sample, 0.002);
-
+    }
     /*empty loop, sample() is executed periodically*/
     while(1) {}
 }
\ No newline at end of file