met comments 710

Dependencies:   mbed QEI HIDScope biquadFilter MODSERIAL FastPWM demomode

Revision:
23:cd0a4eb31a90
Parent:
22:8340aa6676d7
Child:
24:0b5b7ec374e6
--- a/main.cpp	Fri Oct 04 09:20:35 2019 +0000
+++ b/main.cpp	Fri Oct 04 09:38:34 2019 +0000
@@ -8,10 +8,14 @@
 // functies aan PINs toevoegen
 DigitalOut led1(D2);
 FastPWM led(PTA1);
-FastPWM motor(D6);
-DigitalOut motor_dir(D7);
-AnalogIn pot(PTB2);
-InterruptIn button(PTB3);
+FastPWM motor1(D6);
+DigitalOut motor1_dir(D7);
+FastPWM motor2(D5);
+DigitalOut motor2_dir(D4);
+AnalogIn pot1(PTB2);
+AnalogIn pot2(PTB3);
+InterruptIn button1(PTB10);
+InterruptIn button2(PTB11);
 
 // timer opzetten = ticker
 Ticker ticker;
@@ -20,42 +24,57 @@
 QEI encoder(D13,D12,NC,32,QEI::X4_ENCODING);
 QEI encoder_2(D11,D10,NC,32,QEI::X4_ENCODING);
 
-int motordir = 1;
+int motordir1 = 1;
+int motordir2 = 1;
 // aparte functies
 //functie motor aansturen met pot
-void motor_direction()
+void motor_direction1()
 {
     
-    motordir = !motordir;
+    motordir1 = !motordir1;
     led1 = !led1;
     wait_ms(0.1f);
     led1 = !led1;
     wait_ms(0.1f);
-    motor_dir.write(motordir);
+    motor1_dir.write(motordir1);
+}
+void motor_direction2()
+{
+    
+    motordir2 = !motordir2;
+    led1 = !led1;
+    wait_ms(0.1f);
+    led1 = !led1;
+    wait_ms(0.1f);
+    motor2_dir.write(motordir2);
 }
 
 void motor_speed()
 {
-    motor.write(pot);
+    motor1.write(pot1);
+    motor2.write(pot2);
 }
   
 
 void main_loop()
 {   
         motor_speed();
-        if (button.read() == 0){
-            motor_direction();
+        if (button1.read() == 0){
+            motor_direction1();
             }
-            
+        if (button2.read() == 0){
+            motor_direction2();
+            }    
         
 }
 
 int main()
 { 
-    motor_dir.write(motordir);
+    motor1_dir.write(motordir1);
+    motor2_dir.write(motordir2);
     ticker.attach(&main_loop, 0.1f);
     while(true){
-        pc.printf("pot value is (%f),pulse is (%d),pulse 2 (%d)\r\n",pot.read(),encoder.getPulses(),encoder_2.getPulses());
+        pc.printf("pot1(%f),enc1 is (%d),pot2(%f),enc2 is (%d)\r\n",pot1.read(),encoder.getPulses(),pot2.read(),encoder_2.getPulses());
         wait(0.1f);
         };  
 }
\ No newline at end of file