Dependencies:   HIDScope MODSERIAL mbed

Fork of Milestone_1_Motor_DualDirection_potmeter_v2 by Michel Vos

Files at this revision

API Documentation at this revision

Comitter:
michelvos12
Date:
Wed Oct 10 10:47:36 2018 +0000
Parent:
4:fe0b7e7b1de9
Commit message:
should work for combined motor and emg;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r fe0b7e7b1de9 -r 5442448ac4d1 main.cpp
--- a/main.cpp	Wed Oct 03 19:21:32 2018 +0000
+++ b/main.cpp	Wed Oct 10 10:47:36 2018 +0000
@@ -59,20 +59,20 @@
 }
 
 //______Funcion: Motor state + Makes moter do stuf___//
-void Proces_states(void){
+void Proces_states(){
     switch (CurrentState){       
         case forward:                   //Funcion: Forward
-            directionpin = 1;
-            pwmpin.write(scaled_potmeter);  //pwm of motor is potmeter value
+//            directionpin = 1;
+//            pwmpin.write(scaled_potmeter);  //pwm of motor is potmeter value
             led.write(scaled_potmeter);     //led is potmeter value  
             break;
         case stop:                      //Funcion: Stop
                                         // do nothing
             break;
         case backwards:                 //Function: Backwards
-            directionpin = 0;
+//            directionpin = 0;
             c = scaled_potmeter*-1;
-            pwmpin.write(c);            //pwm of motor is potmeter value
+//            pwmpin.write(c);            //pwm of motor is potmeter value
             led.write(c);               //led is potmeter value 
             break; 
     }            
@@ -85,6 +85,7 @@
     pwmpin.period_us(60);               //60 microseconds PWM period, 16.7 kHz
     led.period_us(60);                  //60 microseconds
     ticker.attach(&sendData, 0.005f);   //send data to hidscope 1/0.005 = 200Hz
+    sample_timer.attach(&sample, 0.002);    //for the emg
 
 //______Scale potmeter___________//
     while (true) {  
@@ -109,13 +110,13 @@
 
         wait(0.2f);
         
-/**Attach the 'sample' function to the timer 'sample_timer'.
-* this ensures that 'sample' is executed every... 0.002 seconds = 500 Hz
-*/
-    sample_timer.attach(&sample, 0.002);
+        /**Attach the 'sample' function to the timer 'sample_timer'.
+        * this ensures that 'sample' is executed every... 0.002 seconds = 500 Hz
+        */
 
-    /*empty loop, sample() is executed periodically*/
-    while(1) {}
+
+        /*empty loop, sample() is executed periodically*/
+        //while(1) {}
     }
 
 }