I'm looking to control a LED fade timing with out using a delay and progressively changing the timing of the fade. How would i change the fade from slow to fast to slow? so it starts of fading slow and progressively gets faster until max brightness and then progressively gets slower then repeats. any ideas?
void fade(void)
{
unsigned long now;
now = millis();
if (now >= nextFade) {
nextFade = now + 100; // Next change in one second
if (fadeDir > 0) {
if (fadeBrightness > (255 - fadeDir)) {
fadeDir = - fadeDir;
}
}
else {
if (fadeBrightness < (-fadeDir)) {
fadeDir = - fadeDir;
}
}
fadeBrightness += fadeDir;
analogWrite(fadePin, fadeBrightness);
}
}