Simple motor controller library, using DIR, PWM, nSLP pin like pololu.
MotorControler.h
- Committer:
- sgrsn
- Date:
- 2020-03-04
- Revision:
- 2:543ff0150de1
- Parent:
- 1:ed3dfe4ecc8a
- Child:
- 3:7acc824ca344
File content as of revision 2:543ff0150de1:
#ifndef MOTORCONTROLER_H #define MOTORCONTROLER_H #include "mbed.h" #define FLIP_MOTOR_DIR 0 typedef enum{ CW = 0, CCW = 1, }MotorDirection; class MotorControler { public: MotorControler(PinName DIR, PinName PWM, PinName SLP); void enableDriver(); void disableDriver(); // speed(-1.0 - 1.0) void setSpeed(float speed); // dir(CW, or CCW) void setMotorDirection(MotorDirection dir); // set PWM frequency // frequency[Hz] void setPwmFrequency(float frequency); private: DigitalOut _DIR; PwmOut _PWM; DigitalOut _nSLP; uint8_t reverse_direction; }; #endif