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.
dc_motor.cpp@0:5307ae36f268, 2014-06-14 (annotated)
- Committer:
- mariob
- Date:
- Sat Jun 14 21:56:12 2014 +0000
- Revision:
- 0:5307ae36f268
example to test motion boards
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| mariob | 0:5307ae36f268 | 1 | #include "dc_motor.hpp" |
| mariob | 0:5307ae36f268 | 2 | |
| mariob | 0:5307ae36f268 | 3 | DC_motor::DC_motor (PinName ppwm, PinName pdir): pwm(ppwm), dir(pdir) |
| mariob | 0:5307ae36f268 | 4 | { |
| mariob | 0:5307ae36f268 | 5 | pwm.period(0.001); |
| mariob | 0:5307ae36f268 | 6 | pwm = 0; |
| mariob | 0:5307ae36f268 | 7 | dir = 0; |
| mariob | 0:5307ae36f268 | 8 | } |
| mariob | 0:5307ae36f268 | 9 | |
| mariob | 0:5307ae36f268 | 10 | void DC_motor::speed (float speed) |
| mariob | 0:5307ae36f268 | 11 | { |
| mariob | 0:5307ae36f268 | 12 | dir = speed>0.0; |
| mariob | 0:5307ae36f268 | 13 | pwm = abs(speed); |
| mariob | 0:5307ae36f268 | 14 | } |