v1

Dependencies:   PinDetect TextLCD mbed

Fork of SunflowerMach1 by Milan Draganic

Revision:
1:3500bf8487d0
Child:
3:bebfc64cefe4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MotorDrivers/Motor.cpp	Sat Nov 09 06:49:43 2013 +0000
@@ -0,0 +1,47 @@
+#include "Motor.h"
+
+Motor::Motor() : positiveOut(NC), negativeOut(NC) {
+}
+
+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;
+    }
+    
+    direction = 0;
+    wait_ms(motorDriveTime);
+}
+
+void Motor::stop() {
+
+    positiveOut = 0;
+    negativeOut = 0;
+    direction = 0;
+}