Skip to content

Instantly share code, notes, and snippets.

@nervusvagus
Last active August 13, 2021 23:01
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 nervusvagus/687b7542a13102494af31032f0ffd918 to your computer and use it in GitHub Desktop.
Save nervusvagus/687b7542a13102494af31032f0ffd918 to your computer and use it in GitHub Desktop.
#include <FastLED.h>
#define LED_PIN 10
#define NUM_LEDS 300
#define BRIGHTNESS 55
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];
const uint8_t SweepSize = 32;
CRGBPalette32 PaletteSweep = CRGBPalette32(
CRGB::DarkBlue,
CRGB::DodgerBlue,
CRGB::Green,
CRGB::Green,
CRGB::Green,
CRGB::Green,
CHSV( 90, 255, 255),
CHSV( 90, 255, 255),
CHSV( 90, 255, 255),
CRGB::Yellow,
CRGB::Yellow,
CRGB::Yellow,
CRGB::Yellow,
CRGB::Yellow,
CRGB::Yellow,
CRGB::Gold
);
const CRGB BackgroundColor = CRGB::Red;
void setup() {
delay( 3000 ); // power-up safety delay
FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
FastLED.setBrightness( BRIGHTNESS );
// FastLED.setMaxPowerInVoltsAndMilliamps(5, 2500);
}
void loop() {
FastLED.show();
JellyFishBase() ;
}
void JellyFishBase() {
int sweepPos = (millis() / 40) % NUM_LEDS;
fill_solid(leds, NUM_LEDS, BackgroundColor); // wasteful but easy
for (int i = 0; i < SweepSize; i++) {
int pos = i + sweepPos; // if(pos > NUM_LEDS){ sweepPos = 0;} // if(pos < 0) continue; // not on the strip yet // Serial.println(pos);
pos += NUM_LEDS;
leds[pos % NUM_LEDS] = ColorFromPalette(PaletteSweep, (255 / SweepSize) * i,beatsin8(80, 0, 255), LINEARBLEND); // set color// past the end of the strip
}
for (int i = 0; i < SweepSize; i++) {
int pos = i + sweepPos + (NUM_LEDS / 5); // if(pos > NUM_LEDS){ sweepPos = 0;} // if(pos < 0) continue; // not on the strip yet // Serial.println(pos);
pos += NUM_LEDS;
leds[pos % NUM_LEDS] = ColorFromPalette(PaletteSweep, (255 / SweepSize) * i,beatsin8(80, 0, 255), LINEARBLEND); // set color// past the end of the strip
}
for (int i = 0; i < SweepSize; i++) {
int pos = i + sweepPos + (NUM_LEDS / 5 * 2); // if(pos > NUM_LEDS){ sweepPos = 0;} // if(pos < 0) continue; // not on the strip yet // Serial.println(pos);
pos += NUM_LEDS;
leds[pos % NUM_LEDS] = ColorFromPalette(PaletteSweep, (255 / SweepSize) * i,beatsin8(80, 0, 255), LINEARBLEND); // set color// past the end of the strip
}
for (int i = 0; i < SweepSize; i++) {
int pos = i + sweepPos + (NUM_LEDS / 5 * 3); // if(pos > NUM_LEDS){ sweepPos = 0;} // if(pos < 0) continue; // not on the strip yet // Serial.println(pos);
pos += NUM_LEDS;
leds[pos % NUM_LEDS] = ColorFromPalette(PaletteSweep, (255 / SweepSize) * i,beatsin8(80, 0, 255), LINEARBLEND); // set color// past the end of the strip
}
for (int i = 0; i < SweepSize; i++) {
int pos = i + sweepPos + (NUM_LEDS / 18); // if(pos > NUM_LEDS){ sweepPos = 0;} // if(pos < 0) continue; // not on the strip yet // Serial.println(pos);
pos += NUM_LEDS;
leds[pos % NUM_LEDS] = ColorFromPalette(PaletteSweep, (255 / SweepSize) * i,beatsin8(80, 0, 255), LINEARBLEND); // set color// past the end of the strip
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment