Thursday, 8 August 2013

Why don't I need a decrementing loop to fade OUT an Arduino LED?

Why don't I need a decrementing loop to fade OUT an Arduino LED?

I've moved past blinking an LED, and have successfully begun fading an LED
using the following sketch.
void setup() {
pinMode(12, OUTPUT);
}
void loop() {
for (int i=0;i<255;i++) {
analogWrite(12,i);
delay(10);
}
}
However, I just realized that there's no for(int i=254;i=0;i--) to fade
OUT. Why don't I need that? Is there something in the loop() function that
automatically returns to the beginning state?

No comments:

Post a Comment