Arduino sound equalizer

I'm trying to build a led equalizer using arduino and I want to light up with the frequencies.

And I need a little help on how I should do it cause Im a beginner.

Should I use pulsein() or analogin pin to measure the freqeuencies?

The input will be an audio cable.

• You are probably asking too much from your poor Arduino Uno... To get some inspiration, you may want to take a look at this homodyne detection program, which is conceptually like a single-channel equalizer. You could try to extend it to handle multiple channels, but you will pretty quickly run out of processing power. Oct 10, 2016 at 15:54
• You seem to be describing a spectral display. A graphic equalizer might include one, but is actually a device with a set of sliders or similar controls that allow changing the response in various frequency bands, rather than merely displaying the spectrum as is. That would be even harder with an arduino. Oct 10, 2016 at 20:51
• Ok to make it more clear sorry for this misundarstanding. I want for example to connect the audio cable and have for example 3 leds. And I want the 1st one to light in the range of 50-60hz the 2nd to 60-200 and so on. In "real" time. Oct 10, 2016 at 21:15

There are three steps to doing what you want, and the Arduino is going to struggle with all of them.

First you need to sample a short block of audio into a buffer that is a power-of-two in size with at least double the number of samples that you want to have bars, and at double the frequency of the highest frequency band you are interested in.

Once you have that sample set you then need to perform a Fast Fourier Transform (FFT) on it. This is quite a heavy mathematical operation, but there are integer only implementations of it that work kind of OK on a little Arduino (though a floating point version running on a better chip with FPU, or a DSP version on a chip with a DSP, is more desirable).

Then the third step is to take the results of the FFT (or "buckets") and calculate the power magnitude of each one (basically the square root of the sum of the squares of the real and imaginary values of the bucket - just like Pythagoras with a triangle).

Finally you can plot those power values on your LED bars.

• tushev.org/articles/arduino/9/measuring-frequency-with-arduino This method that he is describing is not possible? Oct 10, 2016 at 20:18
• @user3247715 That is completely different. That allows you to measure the frequency of one discrete (square wave) signal. It does not allow you to differentiate the different frequencies present within a piece of music. For that you require FFT. Oct 10, 2016 at 20:19

Use a MSGEQ7. This IC is a "Seven Band Graphic Equalizer".

Here is its datasheet:

https://www.sparkfun.com/datasheets/Components/General/MSGEQ7.pdf

This method is more efficient, accurate and easier then pulsein() or analogRead(). The IC is fairly cheap and there are many libraries for it.

https://github.com/NicoHood/MSGEQ7

Here is a nice project that I found and that uses that IC. It can be a good souce of inspiration for both your code and your electronics.