Fading HELP

thanks for your suggestions!

I ve tested something and when I think the code could be working its telling me " expected ) befor { token "

here is the new ON/OFF fading code:

if (average >= 600 ) //if the average is high enough
{ led1val = 250; //set the brightness of LED1 - its normal FULL SHINE without fade
LED1ON = millis (); //store what time LED1 was turned on
}
if (average < 600 && (millis () - LED1ON <= 25 ) // if the average has gone below this range and the time elapsed from the
// change of the condition is less or equal 25ms
{ do { led1val -= ledDecay; // start with fading out
analogWrite (ledPin1, led1val); // write the fading value
}
while (led1val > 0); // untill the LED is completly OFF
}

I really didnt think that the fading could be so dificult.... :stuck_out_tongue:
Nothing worked well yet... nonstop looped fading, or just little bit blinking.....

But thanks to your comments I slowly start to understand the data flow :slight_smile: