FastLED 3.9.15
Loading...
Searching...
No Matches

◆ loop()

void loop ( )

Definition at line 97 of file PJRCSpectrumAnalyzer.h.

97 {
98 unsigned int x, y, freqBin;
99 float level;
100
101 if (fft.available()) {
102 // freqBin counts which FFT frequency data has been used,
103 // starting at low frequency
104 freqBin = 0;
105
106 for (x=0; x < matrix_width; x++) {
107 // get the volume for each horizontal pixel position
108 level = fft.read(freqBin, freqBin + frequencyBinsHorizontal[x] - 1);
109
110 // uncomment to see the spectrum in Arduino's Serial Monitor
111 // Serial.print(level);
112 // Serial.print(" ");
113
114 for (y=0; y < matrix_height; y++) {
115 // for each vertical pixel, check if above the threshold
116 // and turn the LED on or off
117 if (level >= thresholdVertical[y]) {
118 leds[xy(x,y)] = CRGB(myColor);
119 } else {
120 leds[xy(x,y)] = CRGB::Black;
121 }
122 }
123 // increment the frequency bin count, so we display
124 // low to higher frequency from left to right
125 freqBin = freqBin + frequencyBinsHorizontal[x];
126 }
127 // after all pixels set, show them all at the same instant
128 FastLED.show();
129 // Serial.println();
130 }
131}
fl::CRGB leds[NUM_LEDS]
int y
Definition simple.h:93
int x
Definition simple.h:92
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
float thresholdVertical[matrix_height]
const unsigned int matrix_height
unsigned int xy(unsigned int x, unsigned int y)
const unsigned int myColor
AudioAnalyzeFFT1024 fft
const unsigned int matrix_width
int frequencyBinsHorizontal[matrix_width]
fl::CRGB CRGB
Definition crgb.h:25
@ Black
<div style='background:#000000;width:4em;height:4em;'></div>
Definition crgb.h:510

References fl::CRGB::Black, FastLED, fft, frequencyBinsHorizontal, leds, matrix_height, matrix_width, myColor, thresholdVertical, x, xy(), and y.

+ Here is the call graph for this function: