Simple LMD18200 Motor Driver Breakout Board Library

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LMD18200.h Source File

LMD18200.h

00001 #ifndef LMD18200_H
00002 #define LMD18200_H
00003 
00004 #include "mbed.h"
00005 
00006 /*
00007     Very simple class for the LMD18200 H-Bridge Breakout Board
00008 */
00009 
00010 class LMD18200{
00011     public:
00012     /*
00013         Constructor for LMD18200 objects
00014         @param pwm  PWM Pin used to set speed
00015         @param dir  Digital Pin used to set direction
00016     */
00017     LMD18200(PinName pwm, PinName dir);
00018     
00019     /*
00020         Set speed of motor
00021         @param spd  The speed of the motor, as a percentage, 
00022                     normalized between 0 and 1
00023     */
00024     void setSpeed(float spd);
00025     
00026     /*
00027         Set the direction of the motor
00028         @param dir  The direction of the motor, 0 or 1: 0 = FWD, 1 = REVERSE
00029                     
00030     */
00031     void setDirection(int dir);
00032     
00033     private:
00034     PwmOut speed;
00035     DigitalOut direction;
00036     /*
00037         Clamps value between lower and upper values
00038     */
00039     float clip(float value, float lower, float upper);
00040 };
00041 #endif