Created
December 31, 2017 07:52
-
-
Save anonymous/dd00089e918725031d25e8874aa4d42e to your computer and use it in GitHub Desktop.
FastLED Meteor with glittering trail
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "FastLED.h" // FastLED library. Please use the latest version | |
// Fixed definitions. Cannot be changed interactively | |
#define LED_DATA 3 // Data pin | |
#define LED_CLOCK 4 // Clock pin | |
#define COLOR_ORDER BGR // GRB for WS2812 and BGR for APA102 | |
#define LED_TYPE APA102 // Using APA102, WS2812, WS2801 - don't forget to change LEDS.addLeds | |
#define NUM_LEDS 234 // Number of LEDs set higher than strip length to have trail vanish fully | |
int head_led = 0; | |
uint8_t max_bright = 32; // Overall brightness | |
struct CRGB leds[NUM_LEDS]; // Initialise LED array | |
void setup() { | |
delay(1000); | |
LEDS.addLeds<LED_TYPE, LED_DATA, LED_CLOCK, COLOR_ORDER>(leds, NUM_LEDS); // For WS2801 or APA102 | |
FastLED.setBrightness(max_bright); | |
} | |
void loop() | |
{ | |
EVERY_N_MILLISECONDS(30) | |
{ | |
fadeToBlackBy(leds, NUM_LEDS, 5); // n/256 = trail length; smaller number = longer trail | |
leds[head_led] = CHSV(0, 0, random8(96,255)); // set hue, saturation, brightness | |
head_led = head_led + 1; // move the head LED one position forward | |
if(head_led == NUM_LEDS){ head_led = 0; } | |
FastLED.show(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment