Slow version

Dependencies:   mbed

Fork of SunflowerMach1 by Milan Draganic

Revision:
0:7447b8021b33
Child:
1:2e7d4aa6e79e
diff -r 000000000000 -r 7447b8021b33 Motor.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Motor.cpp	Fri Nov 08 19:09:47 2013 +0000
@@ -0,0 +1,43 @@
+#include "Motor.h"
+
+Motor::Motor(PinName positivePin, PinName negativePin): positiveOut(positivePin), negativeOut(negativePin) {
+
+}
+
+void Motor::movePositive() {
+
+    direction = 1;
+    move();
+}
+
+void Motor::moveNegative() {
+
+    direction = -1;
+    move();
+}
+
+void Motor::move() {
+
+    positiveOut = 0;
+    negativeOut = 0;
+        
+    switch(direction) {    
+    case 0:
+        return;
+    case 1:
+        positiveOut = 1;
+        break;
+    case -1:
+        negativeOut = 1;
+        break;
+    }
+    
+    wait_ms(motorDriveTime);
+}
+
+void Motor::stop() {
+
+    positiveOut = 0;
+    negativeOut = 0;
+    direction = 0;
+}