Leon Klute / Mbed 2 deprecated EMG_Controller_6

Dependencies:   HIDScope QEI biquadFilter mbed

Fork of EMG_Controller_5 by Nahuel Manterola

Revision:
8:aa03407660f1
Parent:
7:eed677b636d3
Child:
11:c8b6a2b314c3
diff -r eed677b636d3 -r aa03407660f1 servoController.h
--- a/servoController.h	Tue Oct 25 12:35:29 2016 +0000
+++ b/servoController.h	Wed Oct 26 07:59:31 2016 +0000
@@ -2,13 +2,19 @@
 
 Serial pc(USBTX,USBRX);
 PwmOut ServoPWMpin(D9);
+Timeout resetter;
 
+bool readtime = 1;
 double ServoAngle = 89 ;
 float Pulsew = 0.0015;
 double treshold = 0.3;
 bool binary_input_signal = 0;
 bool binary_input_signal_previous = 0;
 
+void set21(){
+    readtime = 1;
+}
+
 void control_servo(double input_signal){
     pc.printf("/n/r %f", input_signal);
     if (input_signal > treshold){                        // convert the emg to a zero or a one
@@ -16,7 +22,9 @@
     } else {
         binary_input_signal = 0;
     }
-    if(( binary_input_signal!= binary_input_signal_previous)&& binary_input_signal){
+    if((( binary_input_signal!= binary_input_signal_previous)&& binary_input_signal)&& readtime){
+        readtime = 0;
+        resetter.attach(&set21, 1);
         if( ServoAngle < 45){                           // check wether it is more opened or closed
             ServoAngle = 89;                            // open 
         }