Fading an LED Strip

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);
}

probably just not an pwm pin "~"..
uno change to pin 6..

Your project in a sim..

have fun.. ~q

1 Like

thank you so much!

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.