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.
main.cpp@0:76b527fa897e, 2012-08-31 (annotated)
- Committer:
- robt
- Date:
- Fri Aug 31 16:07:35 2012 +0000
- Revision:
- 0:76b527fa897e
by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| robt | 0:76b527fa897e | 1 | /*Program Example 4.5: PWM control to DC motor is repeatedly ramped |
| robt | 0:76b527fa897e | 2 | */ |
| robt | 0:76b527fa897e | 3 | #include "mbed.h" |
| robt | 0:76b527fa897e | 4 | PwmOut PWM1(p21); |
| robt | 0:76b527fa897e | 5 | float i; |
| robt | 0:76b527fa897e | 6 | int main() |
| robt | 0:76b527fa897e | 7 | { |
| robt | 0:76b527fa897e | 8 | PWM1.period(0.010); //set PWM period to 10 ms |
| robt | 0:76b527fa897e | 9 | while(1) { |
| robt | 0:76b527fa897e | 10 | for (i=0; i<1; i=i+0.01) { |
| robt | 0:76b527fa897e | 11 | PWM1=i; // update PWM duty cycle |
| robt | 0:76b527fa897e | 12 | wait(0.2); |
| robt | 0:76b527fa897e | 13 | } |
| robt | 0:76b527fa897e | 14 | } |
| robt | 0:76b527fa897e | 15 | } |