Guest User

arduino fastled radiate

a guest
Dec 22nd, 2016
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.78 KB | None | 0 0
  1. #define NUM_LEDS = 150;
  2. int HALF_POS = NUM_LEDS*0.5;
  3.  
  4. void radiate() {
  5.  
  6.     // this is for msgeq7 smoothing. every 10 milliseconds, data is read. not necessary.
  7.     // but it smooths out the data a bit.
  8.   //MILLISECONDS  = 10;
  9.   //lowPass_audio = 0.17;
  10.   //filter_min    = 150;
  11.     // above is a low-pass data filter and data floor. I use these to smooth msgeq7 data in the following math located in my readAudio function:
  12.  
  13.       //prev_value  = left[band];
  14.       //prev_value  -= (prev_value * EQ[band]);
  15.       //left_value  = analogRead(AUDIO_LEFT_PIN);
  16.       //left_value  = constrain(left_value, filter_min, filter_max);
  17.       //left_value  = map(left_value, filter_min, filter_max, value_floor, filter_max );
  18.       //left[band]  = prev_value + (left_value - prev_value) * lowPass_audio;
  19.  
  20.  
  21.   // following code is not entirely necessary. just here to further filter the audio data
  22.   zero  = mono[0] * 0.25;
  23. //  if (zero < 40) {
  24. //    zero -= (zero * 0.10);
  25. //  }
  26.   three = mono[3] * 0.23;
  27.   if (three < 80) {
  28.     three -= (three * 0.25);
  29.   }
  30.   six   = mono[6] * 0.25;
  31.   if (six < 40) {
  32.     six -= (six * 0.10);
  33.   }
  34.  
  35.   leds[HALF_POS] = CRGB(zero, three, six);
  36.  
  37.   EVERY_N_MILLISECONDS(10) {
  38.     for (int i = NUM_LEDS; i > HALF_POS; i--) {
  39.       leds[i].blue = leds[i - 1].blue;
  40.     }
  41.   }
  42.   EVERY_N_MILLISECONDS(20) {
  43.     for (int i = NUM_LEDS; i > HALF_POS; i--) {
  44.       leds[i].green = leds[i - 1].green;
  45.     }
  46.   }
  47.   EVERY_N_MILLISECONDS(50) {
  48.     for (int i = NUM_LEDS; i > HALF_POS; i--) {
  49.       leds[i].red = leds[i - 1].red;
  50.     }
  51.   }
  52.   for (int i = NUM_LEDS; i > HALF_POS; i--) {
  53.     leds[HALF_POS - (i - HALF_POS)] = leds[i - 1];
  54.   }
  55.  
  56.   //blur1d(leds, NUM_LEDS, 5); //blurring the led array a small amount makes for a pretty interesting effect
  57.   FastLED.show();
  58. }
Advertisement
Add Comment
Please, Sign In to add comment