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

◆ loop()

void loop ( )

Definition at line 92 of file PJRCSpectrumAnalyzer.h.

92 {
93 unsigned int x, y, freqBin;
94 float level;
95
96 if (fft.available()) {
97 // freqBin counts which FFT frequency data has been used,
98 // starting at low frequency
99 freqBin = 0;
100
101 for (x=0; x < matrix_width; x++) {
102 // get the volume for each horizontal pixel position
103 level = fft.read(freqBin, freqBin + frequencyBinsHorizontal[x] - 1);
104
105 // uncomment to see the spectrum in Arduino's Serial Monitor
106 // Serial.print(level);
107 // Serial.print(" ");
108
109 for (y=0; y < matrix_height; y++) {
110 // for each vertical pixel, check if above the threshold
111 // and turn the LED on or off
112 if (level >= thresholdVertical[y]) {
113 leds[xy(x,y)] = CRGB(myColor);
114 } else {
115 leds[xy(x,y)] = CRGB::Black;
116 }
117 }
118 // increment the frequency bin count, so we display
119 // low to higher frequency from left to right
120 freqBin = freqBin + frequencyBinsHorizontal[x];
121 }
122 // after all pixels set, show them all at the same instant
123 FastLED.show();
124 // Serial.println();
125 }
126}
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.
Definition FastLED.cpp:74
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]
@ Black
<div style='background:#000000;width:4em;height:4em;'></div>
Definition crgb.h:567
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:86

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

+ Here is the call graph for this function: