Simple LMD18200 Motor Driver Breakout Board Library
Diff: LMD18200.h
- Revision:
- 0:52968fafce73
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LMD18200.h Fri Jan 01 20:40:15 2016 +0000 @@ -0,0 +1,41 @@ +#ifndef LMD18200_H +#define LMD18200_H + +#include "mbed.h" + +/* + Very simple class for the LMD18200 H-Bridge Breakout Board +*/ + +class LMD18200{ + public: + /* + Constructor for LMD18200 objects + @param pwm PWM Pin used to set speed + @param dir Digital Pin used to set direction + */ + LMD18200(PinName pwm, PinName dir); + + /* + Set speed of motor + @param spd The speed of the motor, as a percentage, + normalized between 0 and 1 + */ + void setSpeed(float spd); + + /* + Set the direction of the motor + @param dir The direction of the motor, 0 or 1: 0 = FWD, 1 = REVERSE + + */ + void setDirection(int dir); + + private: + PwmOut speed; + DigitalOut direction; + /* + Clamps value between lower and upper values + */ + float clip(float value, float lower, float upper); +}; +#endif \ No newline at end of file