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@3:a0dc016b7cbb, 2011-07-15 (annotated)
- Committer:
- kaushalpkk
- Date:
- Fri Jul 15 18:04:43 2011 +0000
- Revision:
- 3:a0dc016b7cbb
- Parent:
- 1:88772267f757
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| kaushalpkk | 0:c92be90656b7 | 1 | #include "DCMotor.h" |
| kaushalpkk | 0:c92be90656b7 | 2 | #include "mbed.h" |
| kaushalpkk | 0:c92be90656b7 | 3 | |
| kaushalpkk | 0:c92be90656b7 | 4 | DCMotor::DCMotor(PinName PWMPin, PinName PinA, PinName PinB): |
| kaushalpkk | 1:88772267f757 | 5 | _PWMPin(PWMPin), _PinA(PinA), _PinB(PinB) { |
| kaushalpkk | 1:88772267f757 | 6 | |
| kaushalpkk | 0:c92be90656b7 | 7 | _PWMPin.period(0.001); |
| kaushalpkk | 0:c92be90656b7 | 8 | _PWMPin = 0; |
| kaushalpkk | 1:88772267f757 | 9 | |
| kaushalpkk | 0:c92be90656b7 | 10 | _PinA = 0; |
| kaushalpkk | 0:c92be90656b7 | 11 | _PinB = 0; |
| kaushalpkk | 0:c92be90656b7 | 12 | } |
| kaushalpkk | 0:c92be90656b7 | 13 | |
| kaushalpkk | 0:c92be90656b7 | 14 | void DCMotor::driveIt(float perCent) { |
| kaushalpkk | 0:c92be90656b7 | 15 | if (perCent > 0) { |
| kaushalpkk | 0:c92be90656b7 | 16 | _PinA = 0; |
| kaushalpkk | 0:c92be90656b7 | 17 | _PinB = 1; |
| kaushalpkk | 1:88772267f757 | 18 | |
| kaushalpkk | 0:c92be90656b7 | 19 | } else { |
| kaushalpkk | 0:c92be90656b7 | 20 | _PinA = 1; |
| kaushalpkk | 0:c92be90656b7 | 21 | _PinB = 0; |
| kaushalpkk | 0:c92be90656b7 | 22 | } |
| kaushalpkk | 1:88772267f757 | 23 | _PWMPin = fabs(perCent/100); |
| kaushalpkk | 0:c92be90656b7 | 24 | } |