Skip to content

Instantly share code, notes, and snippets.

@neftaly
Created October 12, 2018 07:51
Show Gist options
  • Save neftaly/19792152ad02184b2e2bbcbeed9d7da7 to your computer and use it in GitHub Desktop.
Save neftaly/19792152ad02184b2e2bbcbeed9d7da7 to your computer and use it in GitHub Desktop.
#include <FastLED.h>
#define DATA_PIN 5
#define LED_TYPE WS2812
#define COLOR_ORDER GRB
#define NUM_LEDS 480
CRGB leds[NUM_LEDS];
int pos = 0;
void setup() {
FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(128);
}
void loop() {
FastLED.show();
tinsel(2, 10);
}
void tinsel(int density, int fade) {
fadeToBlackBy(leds, NUM_LEDS, fade);
for (int i = 0; i < density; i++) {
// Red
pos = random16(NUM_LEDS / 2);
leds[pos] += CHSV(0 + random8(48), 160 + random8(64), 255);
// Green
pos = random16(NUM_LEDS / 2) + NUM_LEDS / 2;
leds[pos] += CHSV(72 + random8(48), 160 + random8(64), 255);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment