emg with text

Dependencies:   HIDScope MODSERIAL biquadFilter mbed

Fork of emg_import by Daniqe Kottelenberg

Revision:
46:4a8889f9dc9f
Parent:
45:08bddea67bd8
Child:
47:ddaa59d48aca
--- a/main.cpp	Wed Nov 02 16:18:25 2016 +0000
+++ b/main.cpp	Wed Nov 02 16:24:59 2016 +0000
@@ -1,19 +1,21 @@
-//==========================================
+
+//=====================================================================================
 //libraries
 #include "mbed.h"
 #include "HIDScope.h"
 #include "BiQuad.h"  
 #include "MODSERIAL.h"
 
-//=========================================
+
+//=====================================================================================
 //Define objects
 AnalogIn    emg_biceps_right_in( A0 );              //analog in to get EMG biceps  (r) in to c++
 AnalogIn    emg_triceps_right_in(A1);               //analog in to get EMG triceps (r) in to c++
 AnalogIn    emg_biceps_left_in  (A2);               //analog in to get EMG biceps  (l) in to c++
-Ticker      sample_timer;           //ticker
-Ticker      ticker_switch;         //ticker
-HIDScope    scope(5);               //open 3 channels in hidscope
-MODSERIAL pc(USBTX, USBRX);            //pc connection
+Ticker      sample_timer;               //ticker
+Ticker      ticker_switch;              //ticker
+HIDScope    scope(5);                   //open 5 channels in hidscope
+MODSERIAL pc(USBTX, USBRX);             //pc connection
 DigitalOut red(LED_RED);
 DigitalOut green(LED_GREEN);
 
@@ -23,6 +25,7 @@
 DigitalOut richting_motor2(D7);
 PwmOut pwm_motor2(D6);
 
+//=====================================================================================
 //define variables
 //other
 int    onoffsignal_rightarm=0;              // on/off signal: 1; biceps activation, 0: nothing, -1, triceps activation
@@ -34,6 +37,12 @@
  
 int onoffsignal_biceps;
 int switch_signal_triceps;
+
+float speedmotor1=0.18;
+float speedmotor2=1.0;
+
+int cw=0;
+int ccw=1;
  
 //=======================================
 //filter coefficients
@@ -173,15 +182,15 @@
     {
          if (switch_signal%2==0)                     
          { 
-           richting_motor1 = 1; //motor 1, left
-           pwm_motor1 = 1; 
+           richting_motor1 = ccw; //motor 1, left
+           pwm_motor1 = speedmotor1; 
                   
          } 
          
          else                           
          {
-           richting_motor2 = 1; //motor 2, up 
-           pwm_motor2 = 1;
+           richting_motor2 = ccw; //motor 2, up 
+           pwm_motor2 = speedmotor2;
            
          }      
               
@@ -190,14 +199,14 @@
     {
          if (switch_signal%2==0)                     // als d is ingedrukt en n is even dan gebeurd het volgende
          {
-           richting_motor1 = 0; //motor 1, right
-           pwm_motor1 = 1;
+           richting_motor1 = cw; //motor 1, right
+           pwm_motor1 = speedmotor1;
            
         } 
          else                           // als d is ingedrukt maar het getal is niet even (dus oneven) gebeurt het onderstaande
          {
-           richting_motor2 = 0; //motor 2. down
-           pwm_motor2 = 1;
+           richting_motor2 = cw; //motor 2. down
+           pwm_motor2 = speedmotor2;
                 
          }  
     }