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@6:b6113cd596c0, 2017-04-19 (annotated)
- Committer:
- jcm931213
- Date:
- Wed Apr 19 07:39:43 2017 +0000
- Revision:
- 6:b6113cd596c0
- Parent:
- 5:de0ba139a472
PWM LED control example
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| jcm931213 | 6:b6113cd596c0 | 1 | |
| justinkim | 0:c4205a3ad6fe | 2 | #include "mbed.h" |
| justinkim | 0:c4205a3ad6fe | 3 | |
| justinkim | 0:c4205a3ad6fe | 4 | |
| jcm931213 | 6:b6113cd596c0 | 5 | PwmOut pwm0(D3); |
| jcm931213 | 6:b6113cd596c0 | 6 | PwmOut pwm1(D5); |
| justinkim | 0:c4205a3ad6fe | 7 | |
| justinkim | 0:c4205a3ad6fe | 8 | |
| justinkim | 0:c4205a3ad6fe | 9 | int main(void) |
| justinkim | 0:c4205a3ad6fe | 10 | { |
| justinkim | 0:c4205a3ad6fe | 11 | int i; |
| justinkim | 0:c4205a3ad6fe | 12 | |
| jcm931213 | 6:b6113cd596c0 | 13 | while(1){ |
| jcm931213 | 6:b6113cd596c0 | 14 | for(i=100; i>0; i=i-10) { |
| jcm931213 | 6:b6113cd596c0 | 15 | pwm0.write(i*0.01); |
| jcm931213 | 6:b6113cd596c0 | 16 | wait(0.05); |
| jcm931213 | 6:b6113cd596c0 | 17 | } |
| jcm931213 | 6:b6113cd596c0 | 18 | |
| jcm931213 | 6:b6113cd596c0 | 19 | for(i=100; i>0; i=i-10) { |
| jcm931213 | 6:b6113cd596c0 | 20 | pwm1.pulsewidth_ms(i*0.01); |
| jcm931213 | 6:b6113cd596c0 | 21 | wait(0.2); |
| jcm931213 | 6:b6113cd596c0 | 22 | } |
| justinkim | 0:c4205a3ad6fe | 23 | } |
| jcm931213 | 6:b6113cd596c0 | 24 | } |

