I wonder, how can i turn on the LED, using fade-effect. WITHOUT turning it off.
I use
int PWMpin = 10; // LED in series with 470 ohm resistor on pin 10
void setup()
{
}
void loop()
{
for (int i=0; i <= 255; i++){
analogWrite(PWMpin, i);
delay(10);
}
}
But, after fading in, the LED just turnes OFF and fade in again and again and forever. And other commands in my code(after for-commands) don't work. How to prevent it from turning off, until the 'analogWrite(PWMpin, 0)' command.
HazardsMind:
If " i " equals zero or if the required minimal voltage is not met, it will turn off.
I mean how to prevent turning it off after it got 255? How to stop for-function from turning it of after each cycle and fade in it again and again.
I want to fade in the LED and let it be turned on, until I analogwrite 0 to it.
Look at the name of the function the for loop is in: loop. Guess what the loop function does after it is finished? That's right it loops and starts again. If you want better control over it, take a look at the blink without delay example. You can add logic to said example that emulates what a for loop does, but without indiscriminately setting the analogWrite value back to 0