mbed_example
/
PwmOut_ex_2
Additional PwmOut example
main.cpp@0:248dfc85bbf9, 2017-01-19 (annotated)
- Committer:
- mab5449
- Date:
- Thu Jan 19 14:22:30 2017 -0600
- Revision:
- 0:248dfc85bbf9
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:248dfc85bbf9 | 1 | #include "mbed.h" |
mab5449 | 0:248dfc85bbf9 | 2 | |
mab5449 | 0:248dfc85bbf9 | 3 | PwmOut led(LED2); |
mab5449 | 0:248dfc85bbf9 | 4 | |
mab5449 | 0:248dfc85bbf9 | 5 | int main() { |
mab5449 | 0:248dfc85bbf9 | 6 | // specify period first, then everything else |
mab5449 | 0:248dfc85bbf9 | 7 | led.period(4.0f); // 4 second period |
mab5449 | 0:248dfc85bbf9 | 8 | led.pulsewidth(2); // 2 second pulse (on) |
mab5449 | 0:248dfc85bbf9 | 9 | while(1); // led flashing |
mab5449 | 0:248dfc85bbf9 | 10 | } |
mab5449 | 0:248dfc85bbf9 | 11 |