Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: ASEE-2014 frdm_Wall
Fork of Motor by
Diff: Motor.cpp
- Revision:
- 3:7f1fd2d62c72
- Parent:
- 2:f265e441bcd9
- Child:
- 4:de727286a2a8
--- a/Motor.cpp Tue Nov 23 16:16:43 2010 +0000
+++ b/Motor.cpp Thu Feb 27 01:40:41 2014 +0000
@@ -24,22 +24,21 @@
#include "mbed.h"
-Motor::Motor(PinName pwm, PinName fwd, PinName rev):
- _pwm(pwm), _fwd(fwd), _rev(rev) {
-
- // Set initial condition of PWM
- _pwm.period(0.001);
- _pwm = 0;
+Motor::Motor(PinName fwd, PinName rev):
+ _fwd(fwd), _rev(rev) {
// Initial condition of output enables
_fwd = 0;
+ _fwd.period(0.001);
_rev = 0;
+ _rev.period(0.001);
}
void Motor::speed(float speed) {
- _fwd = (speed > 0.0);
- _rev = (speed < 0.0);
- _pwm = abs(speed);
+ if(speed > 0.0)
+ _fwd = abs(speed);
+ else
+ _rev = abs(speed);
}
