Juan Camilo Peña
/
Lab01_pwm_
PWM Intervalo 10us hasta 180º
main.cpp@0:f7e145caa35a, 2018-02-15 (annotated)
- Committer:
- JuanCamilo93
- Date:
- Thu Feb 15 02:24:55 2018 +0000
- Revision:
- 0:f7e145caa35a
PWM-intervalos 10us hasta 180?
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JuanCamilo93 | 0:f7e145caa35a | 1 | #include "mbed.h" |
JuanCamilo93 | 0:f7e145caa35a | 2 | |
JuanCamilo93 | 0:f7e145caa35a | 3 | PwmOut mypwm(PA_10); |
JuanCamilo93 | 0:f7e145caa35a | 4 | |
JuanCamilo93 | 0:f7e145caa35a | 5 | DigitalOut myled(LED1); |
JuanCamilo93 | 0:f7e145caa35a | 6 | |
JuanCamilo93 | 0:f7e145caa35a | 7 | int main() { |
JuanCamilo93 | 0:f7e145caa35a | 8 | |
JuanCamilo93 | 0:f7e145caa35a | 9 | int Pos=1000; |
JuanCamilo93 | 0:f7e145caa35a | 10 | |
JuanCamilo93 | 0:f7e145caa35a | 11 | while(Pos<=2000){ |
JuanCamilo93 | 0:f7e145caa35a | 12 | |
JuanCamilo93 | 0:f7e145caa35a | 13 | mypwm.period_ms(20); |
JuanCamilo93 | 0:f7e145caa35a | 14 | mypwm.pulsewidth_us(Pos); |
JuanCamilo93 | 0:f7e145caa35a | 15 | wait(1); |
JuanCamilo93 | 0:f7e145caa35a | 16 | Pos+=100; |
JuanCamilo93 | 0:f7e145caa35a | 17 | |
JuanCamilo93 | 0:f7e145caa35a | 18 | } |
JuanCamilo93 | 0:f7e145caa35a | 19 | while(1) { |
JuanCamilo93 | 0:f7e145caa35a | 20 | myled = !myled; |
JuanCamilo93 | 0:f7e145caa35a | 21 | wait(1); |
JuanCamilo93 | 0:f7e145caa35a | 22 | } |
JuanCamilo93 | 0:f7e145caa35a | 23 | } |