3.5mm jack sound reactive LEDs

i am sorry if this has already been posted, but i did not see one with this specific question.
i am making a 5x5x5 LED cube using an arduino uno and shift registers. i would like to be able to plug a 3.5mm audio cable into the arduino and make the LEDs sound reactive. i know i can use a msgeq7, but i do not need to. i just want the whole cube to blink like one LED would with a 3.5mm cable hooked to a tip31 transistor. any help would be appreciated.

i know i can use a msgeq7, but i do not need to.

You some circuitry to protect the Arduino from the negative voltage-swing, and from any signals above +5V. The diagram on [u]this page[/u] with two diodes and a resistor is a good way to do it. I'd recommend a resistor value of 1K to 5k ohms, instead of 100 Ohms if you have line-level signals (or a headphone signal).* 100 Ohms is fine if you are always going to connect a headphone output.

i just want the whole cube to blink like one LED would

To make an LED blink with sound, here's how I do it:

I take a "reading" once per second and I create a 20-second moving average (See the [u]Smoothing Example[/u] and [u]Blink Without Delay Example[/u] for ideas on how to do this without slowing-down your main loop.)

I read the input signal every time through the main loop, and whenever the signal is louder than average, the LED comes on, and whenever it's lower than average the LED is off. That gives lots of "LED action" (on half the time, and off half the time), and it automatically adjusts to the average volume.

In my application, I also automatically switch between the 1.1 and 5V ADC reference, depending on the signal level.

  • The diodes are protecting the Arduino from the audio signal, and the resistor is protecting your audio device/signal from the diodes.

thank you for the information. so would i just connect the leads from a female 3.5mm plug to the arduino?

thank you for the information. so would i just connect the leads from a female 3.5mm plug to the arduino?

No... You need a protection circuit! Audio signals are AC. They swing positive and negative. The Arduino can be damaged with negative voltages. A headphone signal could also go over 5V peak at high volumes and that can damage the Arduino too.

It's actually unlikely that you get more than 5V unless you connect a power amp, but eliminating that part of the protection circuit will only eliminate one diode. And, when you compare the cost of a diode to the cost of the Arduino... It's up to you to figure-out if it's worth it. :wink:

P.S.
By using this particular protection circuit, we are throwing-away the negative half of the audio waveform. But since the positive and negative halves are roughly equal, we don't need the negative-half to "read" the volume.

You may try one of those circuits:
http://coolarduino.wordpress.com/2012/06/22/audio-input-to-arduino/

Oh ok. I am a complete noob when it comes to this stuff so I apologize. But I am kind of confused by that circuit. Is the D2 diode coming from 5v or ground? Also, what kind of diode should I use?

Magician:
You may try one of those circuits:
http://coolarduino.wordpress.com/2012/06/22/audio-input-to-arduino/

I will probably do this. It is pretty simple. Thank you!