Advertisement
alseambusher

Untitled

Sep 30th, 2024
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. void lightning(String color, int duration)
  2.     {
  3.         CRGB parsed_color = get_color(color);
  4.         unsigned long timer = millis();
  5.  
  6.         while (millis() - timer < duration)
  7.         {
  8.             for (int j = 0; j < NUM_LEDS; j++)
  9.             {
  10.                 if (random(0, 100) > 50)
  11.                 {
  12.                     leds[j] = parsed_color;
  13.                 } else {
  14.                     leds[j] = CRGB::Black;
  15.                 }
  16.             }
  17.             FastLED.show();
  18.             delay(random(10, 100));
  19.             turn_off_leds();
  20.             delay(random(10, 100));
  21.         }
  22.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement