![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
pwm
Dependencies: mbed
main.cpp@2:b558f100a0cf, 2016-10-07 (annotated)
- Committer:
- MechB021
- Date:
- Fri Oct 07 03:57:10 2016 +0000
- Revision:
- 2:b558f100a0cf
- Parent:
- 0:4860a91fb495
pwm
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bcostm | 0:4860a91fb495 | 1 | #include "mbed.h" |
bcostm | 0:4860a91fb495 | 2 | |
bcostm | 0:4860a91fb495 | 3 | PwmOut mypwm(PWM_OUT); |
bcostm | 0:4860a91fb495 | 4 | |
bcostm | 0:4860a91fb495 | 5 | DigitalOut myled(LED1); |
bcostm | 0:4860a91fb495 | 6 | |
bcostm | 0:4860a91fb495 | 7 | int main() { |
bcostm | 0:4860a91fb495 | 8 | |
bcostm | 0:4860a91fb495 | 9 | mypwm.period_ms(10); |
bcostm | 0:4860a91fb495 | 10 | mypwm.pulsewidth_ms(1); |
bcostm | 0:4860a91fb495 | 11 | |
bcostm | 0:4860a91fb495 | 12 | printf("pwm set to %.2f %%\n", mypwm.read() * 100); |
bcostm | 0:4860a91fb495 | 13 | |
bcostm | 0:4860a91fb495 | 14 | while(1) { |
bcostm | 0:4860a91fb495 | 15 | myled = !myled; |
bcostm | 0:4860a91fb495 | 16 | wait(1); |
bcostm | 0:4860a91fb495 | 17 | } |
bcostm | 0:4860a91fb495 | 18 | } |