Basis aansturing projectgroep 3

Dependencies:   Biquad HIDScope MODSERIAL QEI mbed

Revision:
1:d8bb72c9c019
Parent:
0:a2db8cc5d5df
Child:
2:0954eb04bb4c
diff -r a2db8cc5d5df -r d8bb72c9c019 main.cpp
--- a/main.cpp	Mon Oct 03 13:14:39 2016 +0000
+++ b/main.cpp	Mon Oct 03 13:39:28 2016 +0000
@@ -20,6 +20,10 @@
 //-------------------Interrupts-------------------------------
 InterruptIn Dir_L(D0); //Motor Dirrection left
 InterruptIn Dir_R(D1); //Motor Dirrection Right
+InterruptIn OnOff(SW3); //Motor On/off
+
+//------------------Ticker------------------------------------
+Ticker Measure;
 //------------------------------------------------------------
 //--------------------All Motors----------------------------
 //------------------------------------------------------------
@@ -36,6 +40,7 @@
 
 //-----------------------Interrupts-----------------------------
 volatile int Motor_Frequency = 1000;
+volatile bool Active = false;
 void Boot(){
   
     M_L_S.period(1.0/Motor_Frequency);
@@ -52,6 +57,13 @@
 void Switch_Dirr_R(){ // Switching dirrection Right motor
     M_R_D = !M_R_D;
     }
+void De_Activate(){
+    Active = !Active;
+    }
+    
+void Information(){
+    pc.printf("test");
+    }
 
 int main()
 {
@@ -62,12 +74,21 @@
 
     Dir_L.fall(Switch_Dirr_L);
     Dir_R.fall(Switch_Dirr_R); 
+    OnOff.fall(De_Activate);
        
     while (true) {  
        // control= pc.getc();  
-        M_L_S = P_M_L.read()/5.0+0.1;
-        M_R_S = P_M_R.read()/5.0+0.1;
+       if (Active == true){
+            M_L_S = P_M_L.read()/5.0+0.1;
+            M_R_S = P_M_R.read()/5.0+0.1;
+        } else {
+            if(Active == false){
+            M_L_S = 0;
+            M_R_S = 0;
+                }
+        }
+        Measure.attach(Information, 2.0); 
         //wait(1.0f);
-        pc.printf("%f",M_L_S);
+        
     }
 }
\ No newline at end of file