Motor
Dependents: Nucleo_spi 2015_denziben_i2c_S2 Nucleo_Motor Nucleo_Motor ... more
Diff: Motor.h
- Revision:
- 0:1252cd3b995f
- Child:
- 1:4ab6e9768847
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Motor.h Fri Jun 19 06:35:46 2015 +0000 @@ -0,0 +1,38 @@ + +#ifndef PID_H +#define PID_H + +#include "mbed.h" +#define Front 1 +#define Back 2 +#define Stop 3 +#define Free 4 +class Motor { + +public: + + Motor(PinName _pin_h1, PinName _pin_g2, PinName _pin_g1, PinName _pin_h2,PinName _pwm,float Max); + Motor& operator= (float duty) + { + if(duty<0) + { + duty*=-1; + run(Front,duty); + } + else if(duty>0) + { + run(Back,duty); + } + else run(Free,duty); + return *this; + } + void run(int i,float duty); + float min,max; +private: + + float Duty; + BusOut motor; + PwmOut PwmPin; +}; + +#endif /* PID_H */