drewandre

radiate

Jan 21st, 2017
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. int HALF_POS = (NUM_LEDS * 0.5) - 1;
  2.  
  3. void radiate() {
  4.  
  5.   zero  = mono[0];
  6.   three = mono[4];
  7.   six   = mono[6];
  8.  
  9.   leds[HALF_POS] = CRGB(zero, three, six);
  10.  
  11.   // high frequencies = blue = FAST SPEED
  12.   EVERY_N_MILLISECONDS(11) {
  13.     for (int i = NUM_LEDS; i > HALF_POS; i--) {
  14.       leds[i].blue = leds[i - 1].blue;
  15.     }
  16.   }
  17.  
  18.   // mid frequencies = green = MEDIUM SPEED
  19.   EVERY_N_MILLISECONDS(30) {
  20.     for (int i = NUM_LEDS; i > HALF_POS; i--) {
  21.       leds[i].green = leds[i - 1].green;
  22.     }
  23.   }
  24.  
  25.   // low frequencies = red = SLOW SPEED
  26.   EVERY_N_MILLISECONDS(58) {
  27.     for (int i = NUM_LEDS; i > HALF_POS; i--) {
  28.       leds[i].red = leds[i - 1].red;
  29.     }
  30.   }
  31.  
  32.   // for mirroring to the other half of the strip
  33.   for (int i = NUM_LEDS; i > HALF_POS; i--) {
  34.     leds[HALF_POS - (i - HALF_POS)] = leds[i - 1];
  35.   }
  36.  
  37.   FastLED.show();
  38. }
Advertisement
Add Comment
Please, Sign In to add comment