I am trying to do something very simple. I want the LED to fade from full brightness to off. This works... However, the LED turns back on to full brightness and fades again, in a loop. I am not sure why. I think I am missing something obvious. Once the legThreeBrightness decrements to 0, nothing should happen...
int legThreeBrightness = 255;
void setup() {
pinMode(3, OUTPUT);
}
void loop() {
if (legThreeBrightness = 255){
do {
analogWrite(3, legThreeBrightness);
delay(30);
legThreeBrightness = legThreeBrightness -5;
} while (legThreeBrightness >= 0);
}
}
legThreeBrightness = 255
doesn't do what you think it does. Turn up your compiler warnings and pay attention to what it says.