I'm trying to code a single color LED strip to gradually fade in and out, but when I run it it just turns on and off. I'm not sure if I need to adjust the brightness in a different way, or how to go about that route. Any help would be appreciated.
int led = 7;
int brightness = 0;
int fadeAmount = 5;
void setup() {
pinMode(led, OUTPUT);
}
void loop() {
analogWrite(led, brightness);
brightness = brightness + fadeAmount;
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
delay(30);
}