Hi,
I have a sketch that receives IR signals from a remote control to dim and turn LEDs on and off. Currently when I fade the pins up and down it takes a long time, about 15 seconds. My goal is to get a good linear fade that cycles through 255 in about 7-8 seconds.
Here are the dim and brighten functions
/*
decrement brightness of LED identified by ldNumber
*/
void dimLed(byte ledNumber)
{
// only brighten if the pin supports it
if (leds[ledNumber].canDim == true)
{
// if minimum value not reaached
if (leds[ledNumber].value > 0)
{
// decrement brightness
leds[ledNumber].value--;
// apply
analogWrite(leds[ledNumber].pin, leds[ledNumber].value);
}
}
}
/*
increment brightness of LED identified by ldNumber
*/
void brightenLed(byte ledNumber)
{
// only brighten if the pin supports it
if (leds[ledNumber].canDim == true)
{
// if maximum value not reaached
if (leds[ledNumber].value < 255)
{
// increment brightness
leds[ledNumber].value++;
// apply
analogWrite(leds[ledNumber].pin, leds[ledNumber].value);
}
}
}