Chawakorn Chaichanawirote
/
module8-9
Part of FRAB program at FIBO, KMUTT
main.cpp@0:090c08c4dc2a, 2019-03-21 (annotated)
- Committer:
- choyai
- Date:
- Thu Mar 21 12:44:39 2019 +0000
- Revision:
- 0:090c08c4dc2a
initial
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
choyai | 0:090c08c4dc2a | 1 | #include "mbed.h" |
choyai | 0:090c08c4dc2a | 2 | |
choyai | 0:090c08c4dc2a | 3 | PwmOut mypwm(PWM_OUT); |
choyai | 0:090c08c4dc2a | 4 | |
choyai | 0:090c08c4dc2a | 5 | DigitalOut myled(LED1); |
choyai | 0:090c08c4dc2a | 6 | |
choyai | 0:090c08c4dc2a | 7 | int main() { |
choyai | 0:090c08c4dc2a | 8 | |
choyai | 0:090c08c4dc2a | 9 | mypwm.period_ms(10); |
choyai | 0:090c08c4dc2a | 10 | mypwm.pulsewidth_ms(1); |
choyai | 0:090c08c4dc2a | 11 | |
choyai | 0:090c08c4dc2a | 12 | printf("pwm set to %.2f %%\n", mypwm.read() * 100); |
choyai | 0:090c08c4dc2a | 13 | |
choyai | 0:090c08c4dc2a | 14 | while(1) { |
choyai | 0:090c08c4dc2a | 15 | myled = !myled; |
choyai | 0:090c08c4dc2a | 16 | wait(1); |
choyai | 0:090c08c4dc2a | 17 | } |
choyai | 0:090c08c4dc2a | 18 | } |