Advertisement
alseambusher

Untitled

Sep 30th, 2024
618
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1.     void final_1(String color, int duration)
  2.     {
  3.         // exponential backof
  4.         int delay_ms = 50; // ms
  5.         int exponential_delay = 500;
  6.         float rate = 1.1;
  7.         int min_delay = 20;
  8.         unsigned long timer = millis();
  9.  
  10.         CRGB parsed_color = get_color(color);
  11.         while (millis() - timer < duration)
  12.         {
  13.             for (int j = 0; j < NUM_LEDS; j++)
  14.             {
  15.                 leds[j] = parsed_color;
  16.             }
  17.             FastLED.show();
  18.             delay(exponential_delay);
  19.             turn_off_leds();
  20.             delay(exponential_delay);
  21.             if (exponential_delay < min_delay)
  22.             {
  23.                 exponential_delay = min_delay;
  24.             } else {
  25.                 exponential_delay = exponential_delay / rate;
  26.             }
  27.         }
  28.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement