8 years 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 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?

I m using h bridge led driving circuit.I wanted to glow the LED alternatively.when red LED is on infrared must be off and vice versa.My code not working correctly.

posted by vishwas nagekar 30 Apr 2016