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.
Dependencies: mbed
main.cpp@1:7d73836cc7c6, 2020-05-04 (annotated)
- Committer:
- dg81
- Date:
- Mon May 04 13:29:14 2020 +0000
- Revision:
- 1:7d73836cc7c6
- Parent:
- 0:75ca8f5758b2
ca tourne
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| dg81 | 0:75ca8f5758b2 | 1 | #include "mbed.h" |
| dg81 | 0:75ca8f5758b2 | 2 | |
| dg81 | 1:7d73836cc7c6 | 3 | PwmOut led(D3); |
| dg81 | 1:7d73836cc7c6 | 4 | |
| dg81 | 1:7d73836cc7c6 | 5 | int main() { |
| dg81 | 1:7d73836cc7c6 | 6 | // specify period first |
| dg81 | 1:7d73836cc7c6 | 7 | led.period(0.01); // 4 second period |
| dg81 | 1:7d73836cc7c6 | 8 | led.write(0.50); // 50% duty cycle, relative to period |
| dg81 | 1:7d73836cc7c6 | 9 | //led = 0.5f; // shorthand for led.write() |
| dg81 | 1:7d73836cc7c6 | 10 | //led.pulsewidth(2); // alternative to led.write, set duty cycle time in seconds |
| dg81 | 1:7d73836cc7c6 | 11 | while(1){ |
| dg81 | 1:7d73836cc7c6 | 12 | led.write(0.25); // 50% duty cycle, relative to period |
| dg81 | 1:7d73836cc7c6 | 13 | wait(2); |
| dg81 | 1:7d73836cc7c6 | 14 | led.write(0.5); // 50% duty cycle, relative to period |
| dg81 | 1:7d73836cc7c6 | 15 | wait(2); |
| dg81 | 1:7d73836cc7c6 | 16 | led.write(0.75); // 50% duty cycle, relative to period |
| dg81 | 1:7d73836cc7c6 | 17 | wait(2); |
| dg81 | 1:7d73836cc7c6 | 18 | } |
| dg81 | 0:75ca8f5758b2 | 19 | } |
| dg81 | 0:75ca8f5758b2 | 20 | |
| dg81 | 0:75ca8f5758b2 | 21 | |
| dg81 | 0:75ca8f5758b2 | 22 |