Control an H-Bridge using a PwmOut (enable) and two DigitalOuts (direction select)
Fork of Motor by
Revision 3:5dee2bd94b2e, committed 2016-12-11
- Comitter:
- mpereira30
- Date:
- Sun Dec 11 13:46:26 2016 +0000
- Parent:
- 2:f265e441bcd9
- Commit message:
- Motor
Changed in this revision
Motor.cpp | Show annotated file Show diff for this revision Revisions of this file |
Motor.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r f265e441bcd9 -r 5dee2bd94b2e Motor.cpp --- a/Motor.cpp Tue Nov 23 16:16:43 2010 +0000 +++ b/Motor.cpp Sun Dec 11 13:46:26 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); }
diff -r f265e441bcd9 -r 5dee2bd94b2e Motor.h --- a/Motor.h Tue Nov 23 16:16:43 2010 +0000 +++ b/Motor.h Sun Dec 11 13:46:26 2016 +0000 @@ -47,7 +47,7 @@ void speed(float speed); protected: - PwmOut _pwm; + PwmOut _pwm1; DigitalOut _fwd; DigitalOut _rev;