Basically, I'm trying to make a set of LEDs synch up to my subwoofers, I'm using the Line out to have a positive and negative lead that will represent the change in current, but i need a way to input those signals into my arduino so that it can read them, ive been pointed towards the direction of basically creating a ttl current by using a comparator but im not sure how to go about doing that, the line out signal is very weak (around 200-300 mV AC) any advice?
maybe a transistor?
what kind? i dont know much about wiring at all..
There really isn't a "positive" or "negative" lead. Line level for home audio* has two wires - signal and ground. As you say, the signal is AC and it swings positive and negative.
The Arduino can be damaged with negative voltages, or voltages above 5V.
A comparator will work as long as you use a 5V supply. And, as long as you only have one LED (or if all the LEDs on/off at the same time.) Actually, with a comparator you don't need an Arduino!!!! Just connect an LED to the comparator and you're done! Since you are detetcting only the part of the positive waveform, you won't get full brightness, but it might be bright enough, and there are other solutions such as a 555 one-shot, that are cheaper than an Arduino and don't require any software.
The most common way to handle audio is to use a [u]voltage divider[/u] (typically two 10k resistors between 5V and ground) to create a 2.5V bias on an analog input. That takes care of the negative-voltage problem plus you can read/measure the negative half of the waveform. Then put a capacitor in series (0.1uF or more) to block the bias from the audio signal. With the Arduino's 10-bit analog-to-digital converter and the default 5V internal reference, you have 5mV resolution. A line-level signal should give you plenty of signal. You can set an LED trigger threshold in software.
For my lighting effects, I use a [u]peak detector circuit[/u] into an analog input. (Again, this ignores the negative half of the waveform.)
I don't know if this applies to you, but since I'm creating effects, and I'm not trying to "measure" anything, I take a "reading" every second and save it in a 20-second [u]circular buffer[/u]. From that buffer, I can find the moving average, or the recent peak and use that as my threshold. That way, my lighting effect will automatically adjust and respond nicely with loud or quiet songs or at any volume level. (You can make a very simple "flicker" effect but turning the lamp/LED on whenever teh signal is above aveage and off when it's below average.) A very In the past, I've done something similar in analog with just peak detectors, filters, and comparators. To get a wider range, I also select automatically between the internal 1.1V reference and the 5V reference. (You can't use the 1.1V reference if you use the 2.5V bias method.)
- Pro audio uses a 3-wire balanced connection with two "push-pull" signal lines, plus ground.