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.
Revision 3:f057c1dbef0a, committed 2015-02-20
- Comitter:
- Calamaro
- Date:
- Fri Feb 20 17:14:01 2015 +0000
- Parent:
- 2:073d39b53874
- Commit message:
- introducted fading on LED2;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Feb 20 17:02:50 2015 +0000 +++ b/main.cpp Fri Feb 20 17:14:01 2015 +0000 @@ -1,15 +1,21 @@ #include "mbed.h" PwmOut mypwm(PA_5); -int pulse_per = 10; - -int main() { +int pulse_per = 100; -for(int i = 0, i < pulse_per, i++){ - mypwm.period_ms(pulse_per); - mypwm.pulsewidth_ms(i); - - printf("pwm set to %.2f %%\n", mypwm.read() * 100); +int main() +{ + while(1) { + for(int i = 0; i < pulse_per; i++) { + mypwm.period_us(pulse_per); + mypwm.pulsewidth_us(i); + wait(0.01); + } + for(int i = pulse_per; i > 0; i--) { + mypwm.period_us(pulse_per); + mypwm.pulsewidth_us(i); + wait(0.01); + } + } - }