FastLED 3.9.15
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages

◆ loop()

void loop ( )

Definition at line 90 of file PJRCSpectrumAnalyzer.ino.

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

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: