Fading HELP

ups ::slight_smile: (I ll never again make post like this....)

But the led is still fading onceagain and onceagain :-/

I just want to fade out once

Somewhere here is the problem / please look at my RED interpretation of the 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 - does it stop writing millis() to LED1ON
when the if condition is not valid???
/
}
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 - when the led1val will be 0 then the
do loop will stop and than program will check the if statement: the result might be false,
because millis() - LED1ON might be bigger than 25ms - is it right??? */
}