Pages: [1]   Go Down
Author Topic: Lights to music  (Read 562 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 79
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi everyone!

Is there a code out there that takes audio input (such as an ipod) and convert the music into lights (LEDs)?

Will the Arduino be fast enough for this? Thanks!
Logged

Offline Offline
Edison Member
*
Karma: 22
Posts: 1164
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sure!  It depends on what you're trying to do...  In any case, you will need to add some hardware at the analog input.

As a simple project to start experimenting with, you can take several level/loudness readings over several seconds and keep a running-average.   Then,whenever the level is above average, turn an LED on and whenever it's below average, turn it off.   Since the LED is on half the time, that gives you lots of "action", no matter what the volume/signal level.

I've made a system that has 7 lights (actually 7 "channels" with  8 sets of 7 lights each).  It does all kinds of sequences and patterns based on the volume/beat, and there's a "VU meter" effect.  One of the effects is something like I described above.  It sets-up a random pattern and when the signal is louder than average the LEDs toggle (the on-LEDs turn off,and the off-LEDs turn on).

Right now, I'm working on a similar 8-foot tall "VU meter plus" effect with 24 LEDs in the left & right channels.

The hardware issus is that audio signals are AC (the voltage goes positive and negative).   But, the Arduino's analog inputs can't go negative, and they can't go above 5V (or the Arduino can be damaged).

The easiest solution is to bias the input (basically add 2.5V to the input by using some resistors). But, I use a peak detector circuit which throws-away the negative half, and holds the positive voltage for a little while (depending on the RC time constant).  Then, I add a resistor and a couple of "protection diodes."

Oh...  If you bias the input and average and the level, your average will always be equal the the bias (the average of a normal non-biased AC signal is zero, which isn't really useful either).  So, if you want to use a moving average as a reference, you'll have to do something in software, like subtract the bias and use the absolute value of yur readings.
Logged

Offline Offline
Sr. Member
****
Karma: 5
Posts: 422
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

VU Meter


Spectrum Analyzer
http://arduino.cc/forum/index.php?topic=61916.15
Logged

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

Thank you DVDdoug and Lakes! This is very helpful, and I built half of it and it looks like it will work! Thanks guys.
Logged

Offline Offline
Edison Member
*
Karma: 22
Posts: 1164
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In the video Lakes linked to, nothing was done to protect the input from negative voltages.   It worked and the Arduino survived, but it's "bad practice".
Logged

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

Ok...I did not realize this. Thank you for pointing it out, but I did not complete Lake's suggested project...I took your advice and did a little research, then completed the project...Thanks for your help again! (It works)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've built the VU meter (as the video), and its working if I touch the 3,5mm cable (out of the A0).
But if I connect it to the PC or Mobile  phone.. the leds are dark, and serial monitor send me only zeros.. (on A0).
What is the problem?
Thanks
Logged

UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11173
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What is the problem?

There's probably something wrong with your hardware and/or software design - neither of which we can see.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Okay, thank you. My jack-end was the problem. I've sticked down 2 "pieces" of 3 of the jack plug. Now its working good. But now i use only 1 cable of 3, so i havent got any ground. Could it be a problem later?
Logged

UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11173
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i havent got any ground. Could it be a problem later?

Very likely, but we still can't see your hardware design, so who knows?
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Edison Member
*
Karma: 22
Posts: 1164
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Now its working good. But now i use only 1 cable of 3, so i havent got any ground. Could it be a problem later?
Yes.  The ground from the PC/phone needs to be connected to the Arduino Ground.   If it's working without a ground, there may be a ground between the power supplies or somewhere else.  For example, if the USB is connected to your PC, you already have a common ground.

The 3.5mm audio jack's 3 conductors are left-signal, right-signal, and ground.    You need ground plus either a left or right signal (2 wires) for a mono (1 channel) VU meter.  Do NOT connect the left & right audio signals together.   (If you want to use both left & right signals, use another analog input on the Arduino for the 2nd channel.)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

https://www.dropbox.com/s/3ifkkh3it5xuys2/IMAG0766.jpg my installation. All other as in the video.
So I am grounded from the usb? Because I use only this one wire (white), no ground. And working.
Logged

Pages: [1]   Go Up
Jump to: