A simple class which can be used to control a motor through a HBridge (such as the L293).

Dependents:   SimplePIDBot

Revision:
0:a3bcb7eab9d9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HBridgeMotor.cpp	Tue Sep 20 12:54:36 2011 +0000
@@ -0,0 +1,19 @@
+#include "HBridgeMotor.h"
+
+HBridgeMotor::HBridgeMotor(PinName fin, PinName rin):fwd(fin), rev(rin) {
+    power = 0.0;
+}
+
+void HBridgeMotor::set(float power) {
+    if(power >= 0.0) {
+        rev = 0.0;
+        fwd = power;
+    } else {
+        rev = -power;
+        fwd = 0.0;
+    }
+}
+
+float HBridgeMotor::read() {
+    return power;
+}
\ No newline at end of file