Is it possible to reduce the intensity of an led?

cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to reduce the intensity of an led?

618 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by sandy29 on Fri Dec 27 02:14:27 MST 2013
Hi friends,
                I am using LPC812 board.
I want to reduce the intensity(like breathing) of the led which is present in the board using PWM. I wanted to know wether we can control the led by varying the duty cycle(i,e PWM).I am trying to change the Blinky code which is present in the LPC IDE. The led should glow from low intensity to high intensity. Is it possible to do so? Please help me :)

Thanks in advance
sandy
Labels (1)
0 Kudos
9 Replies

320 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by sandy29 on Mon Dec 30 03:45:37 MST 2013
I tried with this code but i am getting only ON/OFF of led. I tried to switch on one led.

[color=#900]main.c[/color]



#include "LPC8xx.h"

#include "lpc8xx_clkconfig.h"
#include "lpc8xx_gpio.h"
#include "lpc8xx_mrt.h"

extern uint32_t mrt_counter;


#define freq (50)

#define PWM (1000)
/*main program*/

void setpwm(int pwncount, uint8_t percentage)
{
uint32_t value;
        if ((pwncount < 0) || (pwncount > 5)) {
return;
}

if (percentage >= 100) {
value = 1;
}
else if (percentage == 0) {
value = cycle + 1;
}

int main(void)
{
uint8_t dutyCycle;
int i, j, count = 1;
GPIOSetDir( 0, 7, 1 );
GPIOSetDir( 0, 17, 1 );
        dutyCycle = 50;
         setPWM(0, dutyCycle);
setPWM(1, dutyCycle);
setPWM(2, dutyCycle);
        while (1) {
dutyCycle += count;
if ((dutyCycle  == 0) || (dutyCycle >= 100)) {
count = -count;
                           for (i = 0; i < 10; i++) {
dutyCycle = 100 - dutyCycle;
setPWM(0, dutyCycle);
setPWM(1, dutyCycle);
setPWM(2, dutyCycle);
                         for (j = 0; j < ( freq / 1); j++) {

}
}
}
               return 0;
}
 delayMs(30);
  }

0 Kudos

320 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MarcVonWindscooting on Sat Dec 28 05:06:59 MST 2013

Quote: Martin84

With the PWM on the LPC812 Board you can control the voltage level applied to each LED (R, G and B) in the RGB-LED. You have to adjust the brightness of the separate LEDs to get different colours.



Controlling brightness by integrating a PWM and thereafter applying the voltage to the highly nonlinear device "LED" is a very poor idea - not only for white LEDs shifting their white point if you do that.
If the PWM is not integrated, then it's exactly what TheFallGuy meant and the integrating device is the observer eye+brain.
0 Kudos

320 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Martin84 on Sat Dec 28 04:59:14 MST 2013
>> An LED can be either ON or OFF. If you want to reduce the apparent brightness, you will have to flash it rapidly (>50Hz).

Nonsense.

With the PWM on the LPC812 Board you can control the voltage level applied to each LED (R, G and B) in the RGB-LED. You have to adjust the brightness of the separate LEDs to get different colours.
0 Kudos

320 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by sandy29 on Fri Dec 27 23:34:00 MST 2013
Sorry for the late reply :)
Thanks for the link, Thank you :)
0 Kudos

320 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wellsk on Fri Dec 27 07:55:53 MST 2013
The SCT/PWM example in the LPC8xx LPCOpen package might work for you.
This example configures the SCT as a 3 channel PWM and attaches each output to an LED which can be adjusted in intensity by altering the on/off ratios. The example fades in and out the LED.
It uses no interrupts or system bandwidth. It might require using a different pin (SCTOUT(n)) for your LED state control. You can map the pin to your LED with the Chip_SWM_MovablePinAssign() function.

You can get the package @ http://www.lpcware.com/content/nxpfile/lpcopen-software-development-platform-lpc8xx-packages
0 Kudos

320 Views
herusetiawan
Contributor II

Hi Team,

I can't get source code from above link, could you share the source code here?

Thanks,

Heru

0 Kudos

320 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Fri Dec 27 04:12:42 MST 2013
You can only do it with code... Lots of ways to do it though:

- Flash on/off in a loop
- use a timer + code in the IRQ
- use a pwm to do it automatically

I am sure there have been forum posts on this subject before - just search.
0 Kudos

320 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by sandy29 on Fri Dec 27 03:12:00 MST 2013
How can i do it? Is it possible to control using code?
0 Kudos

320 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Fri Dec 27 02:47:56 MST 2013
An LED can be either ON or OFF. If you want to reduce the apparent brightness, you will have to flash it rapidly (>50Hz).
0 Kudos