Control an H-Bridge using a PwmOut (enable) and two DigitalOuts (direction select)

Dependents:   NHK2015_slave

Fork of Motor by Simon Ford

Files at this revision

API Documentation at this revision

Comitter:
WAT34
Date:
Tue Oct 27 07:26:56 2015 +0000
Parent:
2:f265e441bcd9
Commit message:
Yanagi adjusted.

Changed in this revision

Motor.cpp Show annotated file Show diff for this revision Revisions of this file
Motor.h Show annotated file Show diff for this revision Revisions of this file
diff -r f265e441bcd9 -r 826e2cff5b02 Motor.cpp
--- a/Motor.cpp	Tue Nov 23 16:16:43 2010 +0000
+++ b/Motor.cpp	Tue Oct 27 07:26:56 2015 +0000
@@ -41,6 +41,10 @@
     _rev = (speed < 0.0);
     _pwm = abs(speed);
 }
+void Motor::brake(void){
+    _fwd = 0;
+    _rev = 0;
+    _pwm = 1;
+}
 
 
-
diff -r f265e441bcd9 -r 826e2cff5b02 Motor.h
--- a/Motor.h	Tue Nov 23 16:16:43 2010 +0000
+++ b/Motor.h	Tue Oct 27 07:26:56 2015 +0000
@@ -45,6 +45,7 @@
      * @param speed The speed of the motor as a normalised value between -1.0 and 1.0
      */
     void speed(float speed);
+    void brake(void);
 
 protected:
     PwmOut _pwm;