8 years ago.

LED on and off using PWM in KL25Z

How to glow External LEDs using PWM in FRDM KL25Z.I m using Red and Infrared LED.I want to glow Red and Infrared alternatively.When red is On infrared must be OFF and vice versa.Need help plzzzzz......

1 Answer

8 years ago.

You can use any DigitalOut or PWM pin to drive an external IR LED. Write your software in such as way that both LEDs are always each others complement. You could also try to use the same pin, but in that case only PTD1 is accessible externally. See here. In this case the external LED should be driven in a mirrored way compared to the onboard LED. So Anode of one LED is pulled up to Vcc through a series resistor and Cathode is pulled low by the pin. The other LED is driven by pin using a series resistor to Anode while the LED Cathode is connected to GND.

Accepted Answer

/media/uploads/vishwas123/led_driver_circuit.jpg Thank u sir.Actually i m using H bridge circuit to drive LED.Still i m not able to get that result.I m connecting p2.3 and p2.2 to PTE20 and PTE21.Need help sir

posted by vishwas nagekar 27 Apr 2016

In this setup you need to make sure that for the disabled LED both the LED PWM pin and the corresponding DAC output are disabled. So for IR LED on: p2.3 is low, DAC pin 10 is high, p2.2 is high and DAC pin 5 is low. I suppose you use the DACs for current limitation? What are the voltages on the LEDs. Make sure you have minimal forward voltages or the LEDs wont work. Depends on the LED, but might need 1.5V or higher. Red LED and IR LED will have different voltages also. Also make sure the KL25 output voltage is high enough to fully shut off the high side transistors and make sure the DAC can provide enough current to drive the low side transistor. Note that the PWMs will activate the transistors at low level (so dutycycle 0% means LED on all the time, dutycycle 100% means LED off all the time).

posted by Wim Huiskamp 28 Apr 2016