Control an H-Bridge using a PwmOut (enable) and two DigitalOuts (direction select)
Dependents: FinalProject_Mutex
Fork of Motor by
Diff: Motor.cpp
- Revision:
- 3:d76429c5c280
- Parent:
- 2:f265e441bcd9
diff -r f265e441bcd9 -r d76429c5c280 Motor.cpp --- a/Motor.cpp Tue Nov 23 16:16:43 2010 +0000 +++ b/Motor.cpp Tue Dec 06 23:02:39 2016 +0000 @@ -25,11 +25,11 @@ #include "mbed.h" Motor::Motor(PinName pwm, PinName fwd, PinName rev): - _pwm(pwm), _fwd(fwd), _rev(rev) { + _pwm1(pwm), _fwd(fwd), _rev(rev) { // Set initial condition of PWM - _pwm.period(0.001); - _pwm = 0; + _pwm1.period(0.001); + _pwm1 = 0; // Initial condition of output enables _fwd = 0; @@ -39,7 +39,7 @@ void Motor::speed(float speed) { _fwd = (speed > 0.0); _rev = (speed < 0.0); - _pwm = abs(speed); + _pwm1 = abs(speed); }