Draaiende motor op commando van knopje (WERKEND)

Dependencies:   Encoder MODSERIAL mbed

Fork of P_controller_motor by Bouke Scheltinga

Files at this revision

API Documentation at this revision

Comitter:
ThomasBNL
Date:
Mon Sep 21 09:31:05 2015 +0000
Parent:
11:c5befe79aa53
Commit message:
Werkende motor: motor draait beide richtingen op commando van knopje

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r c5befe79aa53 -r 27abe8ee588c main.cpp
--- a/main.cpp	Mon Sep 21 09:04:28 2015 +0000
+++ b/main.cpp	Mon Sep 21 09:31:05 2015 +0000
@@ -3,12 +3,23 @@
 #include "encoder.h"
 #include "MODSERIAL.h"
 
-Encoder encoder1(D13,D12);
+//Motor 2
 DigitalOut motor2direction(D4); //D4 en D5 zijn motor 2 (op het motorshield)
 PwmOut motor2speed(D5);
+DigitalIn button(PTA4);
 
 int main()
 {
-    motor2direction = 1;
-    motor2speed = 0.2f;
+    while(true) {
+        if (button.read() < 0.5) {
+            motor2direction = 1;
+            motor2speed = 0.2f;
+        } else {
+            motor2direction = 0;
+            motor2speed = 0.2f;
+        }
+    }
 }
+
+// Geen functie hieronder nog
+Encoder encoder1(D13,D12);
\ No newline at end of file