Dependencies:   mbed

Revision:
0:552b174f8c2f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Motor.cpp	Sun Jan 17 17:17:06 2010 +0000
@@ -0,0 +1,32 @@
+#include "Motor.h"
+#include "mbed.h"
+
+
+/* 
+ * Constructor
+ */
+Motor::Motor(PinName pwm, PinName fwd, PinName rev): 
+    _pwm(pwm), _fwd(fwd), _rev(rev) {    
+    
+    // Set initial condition of PWM
+    _pwm.period(0.001);
+    _pwm = 0;
+
+    // Initial condition of output enables
+    _fwd = 0;
+    _rev = 0;
+
+}
+
+    
+/* 
+ * Set the speed
+ */
+void Motor::speed(float speed) {
+        _fwd = (speed > 0.0);
+        _rev = (speed < 0.0);
+        _pwm = abs(speed);
+}
+
+
+