Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years, 8 months ago.
code to drive LED using PWM
I m trying to blink External led using PWM.I wrote this program.It doesn't work correctly.I m using H bridge as LED driving circuit.I m using FRDM KL25Z.need help plz
<<#include "mbed.h"
PwmOut red_led(PTD4); PwmOut ir_led(PTE20); AnalogOut aout(PTE30); int main() { while(1) { aout=1.0f; red_led.period_ms(40); 4 second period red_led.pulsewidth_ms(20); 2 second pulse (on) wait(0.5); ir_led.period_ms(40); ir_led.pulsewidth_ms(20); }
}>>
1 Answer
8 years, 8 months ago.
Use <<code>> and <</code>>
Also the KL25 has a quite low maximum period, I know it can reach 20ms period, but I don't know if it can do 40ms period. (FastPWM lib can).
What doesn't work correctly?