software to control a DC motor, preferably interfacing with a motor driver.
Diff: DCMotor.cpp
- Revision:
- 1:88772267f757
- Parent:
- 0:c92be90656b7
--- a/DCMotor.cpp Fri Jul 15 10:44:21 2011 +0000 +++ b/DCMotor.cpp Fri Jul 15 17:56:07 2011 +0000 @@ -2,11 +2,11 @@ #include "mbed.h" DCMotor::DCMotor(PinName PWMPin, PinName PinA, PinName PinB): - _PWMPin(PWMPin), _PinA(PinA), _PinB(PinB) { - + _PWMPin(PWMPin), _PinA(PinA), _PinB(PinB) { + _PWMPin.period(0.001); _PWMPin = 0; - + _PinA = 0; _PinB = 0; } @@ -15,10 +15,10 @@ if (perCent > 0) { _PinA = 0; _PinB = 1; - + } else { _PinA = 1; _PinB = 0; } - _PWMPin = fabs(perCent/100); + _PWMPin = fabs(perCent/100); } \ No newline at end of file