Skip to content

Instantly share code, notes, and snippets.

@ScottieD369
Created March 3, 2018 02:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ScottieD369/2cbbe89de53ad82fd5ffdc38382cb083 to your computer and use it in GitHub Desktop.
Save ScottieD369/2cbbe89de53ad82fd5ffdc38382cb083 to your computer and use it in GitHub Desktop.
RGB LED strip Fade
/*
Put together & tested by:
Scottie Digital
*/
#include "FastLED.h"
#define NUM_LEDS 14 // # of LEDS in the strip
#define LED_TYPE WS2812B
CRGB leds[NUM_LEDS];
#define PIN 6 // Output Pin to Data Line on Strip
#define COLOR_ORDER GRB // I had to change this for my strip if your color is off then you know.
int fadeAmount = 5; // Set the amount to fade I usually do 5, 10, 15, 20, 25 etc even up to 255.
int brightness = 0;
void setup()
{
FastLED.addLeds<WS2812B, PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
}
void loop()
{
for(int i = 0; i < NUM_LEDS; i++ )
{
leds[i].setRGB(0,255,250); // Set Color HERE!!!
leds[i].fadeLightBy(brightness);
}
FastLED.show();
brightness = brightness + fadeAmount;
// reverse the direction of the fading at the ends of the fade:
if(brightness == 0 || brightness == 255)
{
fadeAmount = -fadeAmount ;
}
delay(9); // This delay sets speed of the fade. I usually do from 5-75 but you can always go higher.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment