Pages: [1]   Go Down
Author Topic: 3.5mm jack sound reactive LEDs  (Read 2614 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 52
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Edison Member
*
Karma: 37
Posts: 1355
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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 this page 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.

Quote
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 Smoothing Example and Blink Without Delay Example 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.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 52
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Edison Member
*
Karma: 37
Posts: 1355
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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. smiley-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.
« Last Edit: January 15, 2013, 05:48:50 pm by DVDdoug » Logged

Montreal
Offline Offline
Faraday Member
**
Karma: 31
Posts: 2611
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Jr. Member
**
Karma: 0
Posts: 52
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 52
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


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

Pages: [1]   Go Up
Jump to: