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:e53d3f40f2c7, 2012-10-15 (annotated)
- Committer:
- robt
- Date:
- Mon Oct 15 21:18:09 2012 +0000
- Revision:
- 0:e53d3f40f2c7
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:e53d3f40f2c7 | 1 | /*Program Example 5.3: Uses analog input to control PWM period |
| robt | 0:e53d3f40f2c7 | 2 | */ |
| robt | 0:e53d3f40f2c7 | 3 | #include "mbed.h" |
| robt | 0:e53d3f40f2c7 | 4 | PwmOut PWM1(p21); |
| robt | 0:e53d3f40f2c7 | 5 | AnalogIn Ain(p20); |
| robt | 0:e53d3f40f2c7 | 6 | |
| robt | 0:e53d3f40f2c7 | 7 | int main() { |
| robt | 0:e53d3f40f2c7 | 8 | while(1){ |
| robt | 0:e53d3f40f2c7 | 9 | PWM1.period(Ain/10+0.001); // set PWM period |
| robt | 0:e53d3f40f2c7 | 10 | PWM1=0.5; // set duty cycle |
| robt | 0:e53d3f40f2c7 | 11 | wait(0.5); |
| robt | 0:e53d3f40f2c7 | 12 | } |
| robt | 0:e53d3f40f2c7 | 13 | } |
| robt | 0:e53d3f40f2c7 | 14 |