Hello,

as the heading says I am a little bit confused whether or not my problem is completely normal or not.

So I am currently trying to visualise some music on WS2812B LED strips with the Adafruit Neopixel library and in order to capture the music I use the MAX9814 microphone, which is from Adafruit as well. I process the sound with this library:

https://github.com/kosme/arduinoFFT

I will post the code to obtain the frequency using FFT below. My questions are:

1. Is it normal that when there is no music/noise at all, the values kinda "jump" and are pretty random? If not, do you have any ideas on what's wrong with the code?

2. Since I am not 100% sure how the algorithm of FFT completely works I would like to know why the higher the 'SAMPLING_FREQUENCY' the higher the base value when there is silence. For example, if I set it to 1000, I will get a value of around 50 or so when there is silence. So it prints out 50Hz to be the major peak in complete silence. If I set it to 5000 or more however, the major peak is considered to be higher, like at 200Hz.

3. It would also be interesting to know why there is a comment next to that which says that the Hz must be less than 10.000 due to ADC. Why is that the case?

#include "arduinoFFT.h"

#define SAMPLES 512 //Must be a power of 2

#define SAMPLING_FREQUENCY 7500 //Hz, must be less than 10000 due to ADC

arduinoFFT FFT = arduinoFFT();

unsigned int sampling_period_us;

unsigned long microseconds;

double vReal[SAMPLES];

double vImag[SAMPLES];

void setup() {

Serial.begin(115200);

sampling_period_us = round(1000000*(1.0/SAMPLING_FREQUENCY));

}

void loop() {

/*SAMPLING*/

for(int i=0; i<SAMPLES; i++)

{

microseconds = micros(); //Overflows after around 70 minutes!

vReal[i] = analogRead(0);

vImag[i] = 0;

while(micros() < (microseconds + sampling_period_us)){

}

}

/*FFT*/

FFT.Windowing(vReal, SAMPLES, FFT_WIN_TYP_HAMMING, FFT_FORWARD);

FFT.Compute(vReal, vImag, SAMPLES, FFT_FORWARD);

FFT.ComplexToMagnitude(vReal, vImag, SAMPLES);

double peak = FFT.MajorPeak(vReal, SAMPLES, SAMPLING_FREQUENCY);

/*PRINT RESULTS*/

//Print out what frequency is the most dominant.

Serial.println(peak);

delay(100); //Repeat the process over and over

}

Oh, and by the way: Im using a NodeMCU and not an Arduino, if that matters.

I know that those are a lot of questions, but it would be nice if there is anyone, who can answer one of them.

Thanks in advance.