![](/media/cache/group/mbed-logo-square-512_3.png.50x50_q85.png)
Additional PwmOut example
main.cpp@0:07220dd760cc, 2017-01-19 (annotated)
- Committer:
- mab5449
- Date:
- Thu Jan 19 14:22:09 2017 -0600
- Revision:
- 0:07220dd760cc
Initial commit. Ported code snippets to mbed OS 5 projects
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mab5449 | 0:07220dd760cc | 1 | #include "mbed.h" |
mab5449 | 0:07220dd760cc | 2 | |
mab5449 | 0:07220dd760cc | 3 | PwmOut led(LED2); |
mab5449 | 0:07220dd760cc | 4 | |
mab5449 | 0:07220dd760cc | 5 | int main() { |
mab5449 | 0:07220dd760cc | 6 | // specify period first, then everything else |
mab5449 | 0:07220dd760cc | 7 | led.period(4.0f); // 4 second period |
mab5449 | 0:07220dd760cc | 8 | led.write(0.50f); // 50% duty cycle |
mab5449 | 0:07220dd760cc | 9 | while(1); // led flashing |
mab5449 | 0:07220dd760cc | 10 | } |