I'm up to building a light organ for school and want to do it by using a simple spectrum analyzer.
I have already found the perfect code for what I need and have a Mega 2560 sittin around (Arduino: TKs FFTDuino 4: Color Organ Final Form - YouTube), ordered leds, resistors yada yada but I struggle to find a way to get the audio signal from my electret mic into the Arduino. I have already tried some circuits using a transistor but that didn't work at all. And as I want to keep the count of parts and the hassle (classes starting next week already) down to a minimum I thought of using the IC the dude from the video uses. But that filthy TDA7231 is very hard to get in my country and one shop had it listed and available so I ordered there but now it seems they really don't have it and I need an alternative Amp IC which requires the same parts (because I have already ordered them and not the time to order different ones).
The schematic is published if you can't get it where you live and/or you want to build it yourself.
Any op-amp will do. You don't need a "power amplifier". Power amplifiers are designed to drive a speaker.
NOTES:
A "rail-to-rail" op-amp is best if you are running from a single 5V supply.
The op-amp needs to be biased for 2.5V on the output, because the Arduino can't directly handle the negative half of the AC audio waveform. (R2 & R3 in the SparkFun schematic).
The electret mic needs to be biased/powered (R1 & C1).
Yesterday I ordered the Sparkfun Electret Board you pointed to and today it was in my mail .D
I got lucky I found it at all, because I was at the 8th page of google search for that thing and then I found it in an online shop in Berlin. Living nearly 700km southwards that showed what kind of a logistics system we have over here. Amazing.
But I have a problem.
Although the Breaktoutboard is outputting a fine, biased signal when playing music that should be fine for the ADC of the Arduino (I checked that with an osciloscope and compared it against a direct output from my FiiO dac+amp), the code doesn't seem to work properly and I don't know why.
I'm using the pins 22-26, 32-36 and 42-46 on my Arduino but have already tried the regular ones (pin 2-6), the leds just seem to flash as they please. But when I clap, they react like they should. The ones for low and middle frequencies sometimes just don't light untill I do something very loud (e.g. clap) while all the leds for the high frequencies are flashing away. And yes, every band of the frequencies was present in the music I played.
I think it is the code playing a joke on me. I got it from the video of my first post.
It's also attached in this post.
I really don't know how to fix this and your help would be greatly appreciated.
I've tinkered around with it and have found that the constant for smothing neded to be reduced from originally 0.95 to 0.8
But the thing I have noticed is that the leds now follow the music but the output on the low- and mid-range leds is somehow too low.
How do I need to change my code to get all leds to flash like a spectrometer would do?
And one thing: I've hooked up the secondary output of the fiio dac+amp and the output of the electret unit to the two inputs of my osciloscope and found that the electret unit picks up the sound and all frequencies correctly because both waveforms look pretty much the same once synced. And the electret unit saturates the full spectrum of 0..5V so that should be perfectly fine for the arduino's adc.
The problem wasn't the code but it was the power supply. I use a Corsair CX 600 and had the Aurduino plugged into an USB-Port.
When I connected it to a 7.2V racing pack, all the problems went away. Amazing. I didn't think my PC outputs dirty juice.
I even didn't have to use a factor on the low and high band, just an x1.3 factor on the mid frequency band.