Werkcollege opgave 23 september BMT K9

Dependencies:   Encoder HIDScope MODSERIAL mbed QEI biquadFilter

Revision:
4:96e47998d495
Parent:
3:2785a945b654
Child:
5:d60a42727a3e
--- a/main.cpp	Wed Sep 23 09:10:59 2015 +0000
+++ b/main.cpp	Wed Sep 30 15:19:10 2015 +0000
@@ -1,18 +1,37 @@
 #include "mbed.h"
-#include "HIDScope.h"
 #include "encoder.h"
 #include "MODSERIAL.h"
 
 //Motor 2
 DigitalOut motor2direction(D4); //D4 en D5 zijn motor 2 (op het motorshield)
 PwmOut motor2speed(D5);
-DigitalIn button(PTA4);
+DigitalIn buttonL1(PTC6);
+DigitalIn buttonL2(PTA4);
+DigitalIn buttonH1(D2);
+DigitalIn buttonH2(D6);
+
+//dit kan worden gebruikt om de verschillende slagnelheden toe te passen door de buttons te veranderen in thresholds
 
 int main()
 {
-    for (int n = 0; n < 10; n++) {
-        motor2direction = 1;
-        motor2speed = 0.1f*n;
-        wait (2);
+    while(true) {
+        if (buttonL1.read() <0.5) {
+            motor2speed = 0.1;
+            motor2direction = 0;
+        }
+        if (buttonL2.read() <0.5) {
+            motor2speed = 0.4;
+            motor2direction = 0;
+        }
+        if (buttonH1.read() <0.5) {
+            motor2speed = 0.7;
+            motor2direction = 0;
+        }
+        if (buttonH2.read() <0.5) {
+            motor2speed = 0.99999;
+            motor2direction = 0;
+        } else {
+            motor2speed =0;
+        }
     }
-}
\ No newline at end of file
+}