Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Icicle drop
- *
- * By: Andrew Tuline
- *
- * Date: June, 2020
- *
- * Just a simple icicle drop. Could do with a direction parameter, terminal velocity and more. .
- *
- */
- #include <FastLED.h>
- #define LED_DT 12
- #define LED_CK 11
- #define COLOR_ORDER GRB
- #define LED_TYPE WS2812
- #define NUM_LEDS 30
- uint8_t max_bright = 255;
- struct CRGB leds[NUM_LEDS];
- CRGBPalette16 currentPalette = OceanColors_p;
- void setup() {
- Serial.begin(115200);
- delay(1000);
- LEDS.addLeds<LED_TYPE, LED_DT, COLOR_ORDER>(leds, NUM_LEDS);
- FastLED.setBrightness(max_bright);
- } // setup()
- void loop () {
- drop();
- FastLED.show();
- } // loop()
- void drop() {
- static double dropLocn = (NUM_LEDS-1);
- static double dropSpd = 0;
- const double grav = .0008; // Let's just use floating point and be done with it.
- fadeToBlackBy(leds, NUM_LEDS, 32);
- CRGB color = ColorFromPalette(currentPalette, 192,128, LINEARBLEND);
- fill_solid(leds+NUM_LEDS-6, 6, color);
- dropSpd += grav;
- dropLocn -= dropSpd;
- if ((dropLocn) > 0 ) {
- leds[(int)dropLocn] = ColorFromPalette(currentPalette, 192, 255, LINEARBLEND);
- } else {
- dropLocn = (NUM_LEDS-1); dropSpd = 0;
- }
- } // drop()
Advertisement
Add Comment
Please, Sign In to add comment