Motor
Dependents: Nucleo_spi 2015_denziben_i2c_S2 Nucleo_Motor Nucleo_Motor ... more
Diff: Motor.h
- Revision:
- 3:dea2df71cb97
- Parent:
- 1:4ab6e9768847
- Child:
- 4:56a1159c881c
--- a/Motor.h Tue Aug 18 04:44:54 2015 +0000 +++ b/Motor.h Wed Sep 23 06:01:10 2015 +0000 @@ -8,28 +8,41 @@ #define Stop 3 #define Free 4 class Motor { - +protected : PinName Pin[5]; + 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,float Max); + Motor(PinName _pin_h1, PinName _pin_g2, PinName _pin_g1, PinName _pin_h2,PinName _pwm); + + Motor& operator= (float duty) { - if(duty<-0.01) + if(duty<-0.00001F) { duty*=-1; run(Back,duty); } - else if(duty>0.01) + else if(float(duty)>0.00001F) { run(Front,duty); } - else run(Free,duty); + else run(Stop,duty); return *this; } - void setup(int _state); void run(int i,float duty); float min,max; + 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;