Overzetten

Dependencies:   HIDScope MODSERIAL mbed

Revision:
7:d57eba2aed38
Parent:
6:bbef54156775
Child:
8:81f2c8ae4427
--- a/main.cpp	Mon Oct 08 10:48:52 2018 +0000
+++ b/main.cpp	Mon Oct 08 13:18:17 2018 +0000
@@ -18,6 +18,13 @@
 HIDScope    scope( 2 );
 DigitalOut  led(LED1);
 
+volatile float Bicep_Right = 0.0;
+
+void EMG_Read()
+{
+    Bicep_Right = emg0.read();
+    pc.printf("%f ", Bicep_Right);
+}
 
 void sample()
 {
@@ -30,7 +37,9 @@
 }
 
 int Turn_Motor1()
-{
+{   
+    
+
     if(!Knop1 && !Knop3 == true) // Motor 1 rotates CW
         {
             PwmPin1 = fabs(0.0); 
@@ -52,8 +61,8 @@
             PwmPin1 = fabs(u);
             PwmPin2 = fabs(0.0);  
         }
-        /*
-        else if (Biceps_Rechts > )
+        
+        else if (Bicep_Right > 0.7f)
         {
             float u = 0.8f; //determine useful value, this is not final
             DirectionPin1 = u > 0.0f; //either true or false
@@ -61,7 +70,7 @@
             PwmPin1 = fabs(u);
             PwmPin2 = fabs(0.0); 
         }
-        */
+        
         else
         {  
             float u = 0.0f;
@@ -102,24 +111,17 @@
     return 0;
 }
 
-int main()
+int main()//Ticker toevoegen
 {
-    
     pc.baud(115200);     
     sample_timer.attach(&sample, 0.002);
     PwmPin1.period_us(120); //60 microseconds pwm period, 16.7 kHz 
-    /*
-    for(;;)
+
+    while(true)
     {
-        double Biceps_Rechts = emg1.read();
-        double Biceps_1      = emg0.read();
-        pc.printf("%d  en %d      ", Biceps_Rechts, Biceps_1);
-        wait(0.8);
-    }
-    */
-    for(;;)
-    {
+        EMG_Read();
         Turn_Motor1();
-        Turn_Motor2();        
+        Turn_Motor2();   
+        pc.printf("%f     ", Bicep_Right); 
     }
 }
\ No newline at end of file