Control an H-Bridge using a PwmOut (enable) and two DigitalOuts (direction select). (forked from simon/Motor and changed according to our needs)
Fork of Motor by
Diff: Motor.h
- Revision:
- 3:118c5f0675da
- Parent:
- 2:f265e441bcd9
--- a/Motor.h Tue Nov 23 16:16:43 2010 +0000 +++ b/Motor.h Sun Oct 27 09:15:12 2013 +0000 @@ -25,6 +25,14 @@ #include "mbed.h" + + +struct mState { + bool en; + bool fwd; + bool rev; +}; + /** Interface to control a standard DC motor * * with an H-bridge using a PwmOut and 2 DigitalOuts @@ -38,16 +46,19 @@ * @param fwd A DigitalOut, set high when the motor should go forward * @param rev A DigitalOut, set high when the motor should go backwards */ - Motor(PinName pwm, PinName fwd, PinName rev); + Motor(PinName en, PinName fwd, PinName rev); /** Set the speed of the motor * * @param speed The speed of the motor as a normalised value between -1.0 and 1.0 */ - void speed(float speed); + void direct(int dir); + void speed(float timeval, float speed); + mState getState(); + void setState(mState); protected: - PwmOut _pwm; + DigitalOut _en; DigitalOut _fwd; DigitalOut _rev;