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