Motor
Dependents: Nucleo_spi 2015_denziben_i2c_S2 Nucleo_Motor Nucleo_Motor ... more
Motor.h
- Committer:
- kikoaac
- Date:
- 2015-10-30
- Revision:
- 4:56a1159c881c
- Parent:
- 3:dea2df71cb97
- Child:
- 5:3b639d84a95d
File content as of revision 4:56a1159c881c:
#ifndef Motor_H #define Motor_H #include "mbed.h" #define Front 1 #define Back 2 #define Stop 3 #define Free 4 class Motor { protected : PinName Pin[5]; float bias; Motor(const Motor& m); Motor& operator=(const Motor &m) { return *this; } public: Motor(PinName _pin_h1, PinName _pin_g2, PinName _pin_g1, PinName _pin_h2,PinName _pwm); Motor& operator= (float duty) { if(duty<-0.1F) { duty*=-1; run(Back,duty); } else if(float(duty)>0.1F) { run(Front,duty); } else run(Stop,0); return *this; } void run(int i,float duty); float min,max; void setbias_motor(float b){bias=b;} void duty_max(float Max){max=Max;} void duty_min(float Min){min=Min;} float getduty() { float a = PwmPin.read(); return a; } private: int state; float Duty; BusOut motor; PwmOut PwmPin; }; #endif /* PID_H */