Electronic – arduino – Handling audio signals on a 5v ADC

arduinoaudiooperational-amplifier

Some days ago I have made a multiplexed 3×8 LED grid based on Arduino RGB Controller. In my case I don't use RGB but row1, row2 and row3. While I already made some nice animations but I'm not really happy with the result. The matrix is 1m x 2,8m, I'm planing to append it over some sort of "home music studio". As you know visualizing audio stuff is cool! So the static animations on that LED matrix would be useless if not following the beat. I need to add a spectrum analyer. Luckly all the analog I/O are free to use.
Another point that makes this grid perfect for a 8 channel spectrum analyzer is the fact that I'm allowed to use PWM on the 3 rows. This means I have a theoretical spectrum grid of 256*3 x 8. Naturally the curve from 0-100% of the LED's brighness is not linear, that can be solved by using a simeple exponential function. Anyway the animation should be nicer than just fully turning on/off the LEDs.

First of all let me tell you again, I'm not an electronical enginer and I doing my best to understand stuff by myself, but in this case I'm not able to do it properly. My only measuring system is a very slow limited multimeter. I also broke an arduino some months ago, so I don't just connect stuff.

Can the arduino create a spectrum analyzer using only one pin?

yes! FHT

And so I started to read about that

  1. I need to somehow convert the audio signal to 0-5V
  2. I need to read the data on the ADC0 (left audio channel) and do some math and send it to the LEDs.

I'm stuck at point 1.

Every Audio device headphones output's max defer so I need a potentiometer.
The audio voltage is low milliamps but also most of the time lower voltage.

From the various circuits I choosed the following one. Before I connected it to the arduino I used a buzzer to test if I get something out. Yes but, I get sound if I invert GND with signal(Jack in) and I also get sound if I invert the polarity of the capacitor C1.
There is also no type of protection in this circuit, I am stucked.

Note.: I also tested differnt other circuits and got alwasy the same results, except in this the potentiometer has no effect.

enter image description here

Result:

With a simple analog read I always get 0(ZERO).

schematic

simulate this circuit – Schematic created using CircuitLab

Reading more about the problem I found many posts that use op-amps.
Since my local electronics component store has only a limited number of IC's, I sometimes buy random IC's if they are compatible with Arduino and other microcontrollers.
And I also salvage old stuff. Here is a list of components I could use.

  1. MC1458 DUAL General-purpose operational amplifier
  2. TDA2822M DUAL low-voltage power amplifier
  3. UA741CN General-purpose single operational amplifier
  4. AD7395 Dual, Serial-Input 12-/10-Bit DAC

As I have no oscilloscope and other professional stuff to measure electronic current, I hope you can show me how to properly connect an audio signal to my microcontroller's ADC.

Consider the fact that I know nothing. Complex explaination without a schematic wouldn't help to solve the problem for me and probably many other people.

The question:

How to PROPERLY connect a standard headphone jack (mp3 player)/ audio out cable to a 0-5V Analog to digical converter Microcontroller's pin?

Main problems:

  1. With the tested online available circuits I get no readings from analog pin 0.
    Analog pin 0 works perfectly (tested potentiometer only).
  2. Now, I don't want to connect something to the MC's pins without knowing for sure that I output 0-5V at the correct amperage.

Extra:

  1. I don't know why I always get reading 0 from Arduino even if I can hear the buzzer?
  2. I never used a op-amp so I don't know what inverting input and non-inverting input is?
  3. What does the C1 capacitor and why does it work if I invert the polarity?(buzzer)
  4. Inverted audio cable pins also produce the same sound on a buzzer, why?
  5. I'm testing on an Arduino micro but the final line in would be used on a Arduino micro, not sure if relevant.

EDIT 1

This uses the same op-amp I have

Noise can be horrible !

https://bochovj.wordpress.com/2013/06/23/sound-analysis-in-arduino/
https://bochovj.files.wordpress.com/2013/06/circuitschematics.png

EDIT 2

Arduino Prescaler: up to 19kHz, not 17 what I have written in the comments.

http://apcmag.com/arduino-project-audio-spectrum-analyser.htm/

But by knocking down the 128-prescaler to 32, we now increase the
sample rate by the same factor up to 38.4kHz. Thanks to Nyquist again,
that gives us an audio bandwidth of 19.2kHz, which is close enough to
20kHz-perfection.

EDIT 3

schematic

simulate this circuit

Best Answer

This should do what you are asking - it takes the audio in (AC-coupled) and amplifies it (inverted, but that won't matter) with a variable gain of up to about 5.5 (use R1 to adjust gain). It also centre-biases the signal around 2.5V (analogRead = 512 on the Arduino).

schematic

simulate this circuit – Schematic created using CircuitLab

However, please do pay attention to the other comments on here regarding sampling rates and the amount of processing needed to be done to get the result you want. Also, don't swap out the opamp without some thought - that part is rail-to-rail input and output rated, which you will need in order to use the full input range of the Arduino's ADC.