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.
DCMotor.cpp
- Committer:
- kaushalpkk
- Date:
- 2011-07-15
- Revision:
- 3:a0dc016b7cbb
- Parent:
- 1:88772267f757
File content as of revision 3:a0dc016b7cbb:
#include "DCMotor.h"
#include "mbed.h"
DCMotor::DCMotor(PinName PWMPin, PinName PinA, PinName PinB):
_PWMPin(PWMPin), _PinA(PinA), _PinB(PinB) {
_PWMPin.period(0.001);
_PWMPin = 0;
_PinA = 0;
_PinB = 0;
}
void DCMotor::driveIt(float perCent) {
if (perCent > 0) {
_PinA = 0;
_PinB = 1;
} else {
_PinA = 1;
_PinB = 0;
}
_PWMPin = fabs(perCent/100);
}