Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Main Goal: Analog Strip fades from one defined hue to a second defined hue
- //Secondary Goal: 4 analog strips repeating this action with each delayed slightly. (2 Variables to define delay amount and overall speed fade occurs)
- #include "FastLED.h"
- // fast led constants
- // #define DATA_PIN 3 // change to your data pin
- // #define COLOR_ORDER GRB // if colors are mismatched; change this
- #define NUM_LEDS 1 // change to the number of LEDs in your strip
- #define REDPIN 5
- #define GREENPIN 6
- #define BLUEPIN 3
- // change WS2812B to match your type of LED, if different
- // list of supported types is here:
- // https://github.com/FastLED/FastLED/wiki/Overview
- //#define LED_TYPE WS2812B
- // this creates an LED array to hold the values for each led in your strip
- CRGB leds[NUM_LEDS];
- // fill_gradient variables (except direction as I wasn't sure what variable type to make it?)
- int start_pixel = 0;
- int end_pixel = 0;
- CHSV start_hue = CHSV(0, 255, 100);
- CHSV end_hue = CHSV(180, 255, 100);
- void showAnalogRGB( const CRGB& rgb)
- {
- analogWrite(REDPIN, rgb.r );
- analogWrite(GREENPIN, rgb.g );
- analogWrite(BLUEPIN, rgb.b );
- }
- void setup()
- {
- // the wiki features a much more basic setup line:
- // FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
- }
- void loop()
- {
- /*
- arguments are:
- array: the name of your "CRGB name[NUM_LEDS] definition above
- start_led: which index number (0 is first pixel) to start with?
- start_hue: CHSV form (hue, sat, bright) of color/brightness for start led
- end_led: which is the last pixel in the gradient?
- end_hue: CHSF form for color of last pixel in gradient
- direction: thinking of a 0-255 color wheel, which direction should the
- gradient ramp through? Change the below to SHORTEST_HUES and you'll
- see that it goes red to blue through violet. Compare that to this, which
- goes the "long way" through yellow, green, and cyan.
- directions explained here: http://fastled.io/docs/3.1/colorutils_8h_source.html
- */
- fill_gradient(leds,
- start_pixel,
- start_hue,
- end_pixel,
- end_hue,
- LONGEST_HUES);
- showAnalogRGB( leds);
- delay(1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment