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.
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, 8 months 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.
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 27 Apr 2016In 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 28 Apr 2016