Guest User

Audio Juggle

a guest
Jul 17th, 2017
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.65 KB | None | 0 0
  1. void Ajuggle()
  2. {
  3.   static uint8_t    numdots =   7; // Number of dots in use.
  4.   static uint8_t   faderate =   2; // How long should the trails be. Very low value = longer trails.
  5.   static uint8_t   basebeat =   5;
  6.  uint8_t blurAmount = dim8_raw( beatsin8(3,64, 172) );       // A sinewave at 3 Hz with values ranging from 64 to 192.
  7.   blur1d( leds, NUM_LEDS, blurAmount);                        // Apply some blurring to whatever's already on the strip, which will eventually go black.
  8.  
  9.   static uint8_t lastSecond =  99;  // Static variable, means it's only defined once. This is our 'debounce' variable.
  10.   uint8_t secondHand = (millis() / 1000) % 30; // IMPORTANT!!! Change '30' to a different value to change duration of the loop.
  11.  
  12.   if (lastSecond != secondHand) { // Debounce to make sure we're not repeating an assignment.
  13.     lastSecond = secondHand;
  14.     switch (secondHand) {
  15.       case  0:  basebeat = 7;  faderate = 12;  break; // You can change values here, one at a time , or altogether.
  16.       case 10:  basebeat = 5;  faderate = 24;  break;
  17.       case 20:  basebeat =  3;  faderate = 32;  break; // Only gets called once, and not continuously for the next several seconds. Therefore, no rainbows.
  18.       case 30: break;
  19.     }
  20.   }
  21.  
  22.   // Several colored dots, weaving in and out of sync with each other
  23.  // curhue = thishue; // Reset the hue values.
  24.   fadeToBlackBy(leds, NUM_LEDS, faderate);
  25.   for ( int i = 0; i < numdots; i++) {
  26.     //beat16 is a FastLED 3.1 function
  27.     leds[beatsin16(basebeat + i + map(spectrumByte[i],0,255,1,5), 0, NUM_LEDS)] += CHSV(i*40 + map(spectrumByte[i],0,255,1,20), 255, map(spectrumByte[i],0,255,30,255));
  28.   }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment