I'm busy with brainstorming about a new project of mine, a massive LED VU meter with ~250 LED's.

but as a start, before buying a few shift registers, i'l use 10 LED's ;) but how do i use a audio signal (from my line out) as a analog input? and then as a variable with 1023 (or 1024?) steps.

and after that, is it possible to control the lights like this

if var0 (the variable) is equal or higher than 100 put LED0 on if var0 is equal or higher than 200 put LED1 on etc.

thanks for any help, oddish2211

You will need to filter the input to slow down the changes and create a variable DC signal.

and do you have an idea how to do that?

This might help http://101science.com/dsp.htm

you probably also need to amplify the audiosignal. You will only get values in the 0 - 1023 range from the ADC if the audio signal is in the 0 - 5 range.

isn't there an easier way? because i'm just a beginner on microcontrollers.

isn't it possible to directly connect the audio cable to analog0 and the ground to the ground?

I posted this only a couple days ago in another thread: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1221551839/24#24

Oh, here's a demo of that circuit controlling some shiftbrites: http://www.youtube.com/watch?v=MGP3x-mrZ8g

You cant expect it to work by just connecting the audio signal to an analog in. The audiosignal is way too week.

Each of the 1024 steps in the analog to digital conversion represents about 4.88 mV.

if you connect a very week signal, you wil only use a very little part of the 0 - 1023 range of the ADC. You would end up with very low readings even if the music is loud.

You really need to do something like what Macegr showed in the shiftbtight post.

EDIT: I can really recomend Tom Igoes book “Physical computing” it explains in great detail hooking just about anything up to a microcontroller, including an example involving audio. If you are a beginner in electronics, programming or microprocessors, this book will get you going. It’s a goldmine!!

if i build the first circuit on that page twice for each channel, it'll give me an analog input ranging from 0 to 1023?

---- edit

i've just found a small audio amplifier based on a TDA 7052, is it possible to just plug an audio cable into the amplifier and instead of connecting an speaker just the arduino's analog input? (or will this fry my arduino? and if i put a potmeter between the devices?)

The problem is not so much that the Arduino can't handle the voltage, or the voltage is too low...audio outputs are usually around 1 volt peak to peak. Mainly it's because the audio is very fast positive and negative voltages, and the Arduino can't sample fast enough to read every value of the signal. So you'd essentially end up with random numbers, or very fast flickering. You need a rectification circuit like the one I posted (it's a variation on a very common "ideal diode" circuit). It will look at only the positive half of the signal, and integrate a lot of the audio waveform to a response the Arduino can measure easily. You can do more in software by averaging samples to slow the result even further. I found that this circuit would give me approximately 0 to 4 volts, as you can see in the simulation graph.

i know, you want to use your arduino ...

but take a look at these chips from national.com

LM3914, LM3915 & LM3916 these are made for this... they are very well documented at their website.

In the appnotes are also the problems discussed how to get the AC signal in AFAIR. The problem is to get it in the right range. So this may take you a step further.

This may not be exact: the audio signal from a line signal should have a maximum voltage of ca. 1V. You have to amplify it to a maximum of 5V. If not you loose the fine grained information. If its above 5V ... you may blow your arduino. Or the signal clips. But on the other side... you may get a maximum reading for 1V at the analog pin lets say of 200, for 10 LED´s that may be enough. Test it, divide it with 10, or make it logarithmic...

And i also would get the Tom Igoe book. It is awesome!

Hope that helps a bit...