mbed_example
/
PwmOut_ex_2
Additional PwmOut example
main.cpp@1:cab93cb2f242, 2017-06-23 (annotated)
- Committer:
- sarahmarshy
- Date:
- Fri Jun 23 16:07:16 2017 -0500
- Revision:
- 1:cab93cb2f242
- Parent:
- 0:248dfc85bbf9
"Update mbed-os"
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 |