Sound to light controller with PWM project, partyvan essentials.

Hi, this is my first Arduino project and i need some help.
I wanna make a sound to light controller for LED strips that use PWM to make the LEDs flicker in sync with the beat. My idea was to use the subwoofer channel as source by using the RCA wire going to the subamp and have a Arduino control the LEDs (like this, but in the sub channel as source, not a mic).

To make it alot more fun, this is to be installed in a older Volkswagen Caravelle.
Where i come from this is our graduation, making party vans out of old cars and driving around partying for 3 weeks straight...
So, since i work at a Radio Shack-ish shop with alot of Arduino stuff, i thought i will do something different with our partyvan.

Im completely new to Arduino, but i have always tinkered with electronics and i have a fairly good base understanding of it. Im reading alot on Arduino (this, amoung others) and learning/tinkering as i go , something im used to. So to my problems and concerns:

  • Input signal and coding: If im not mistaken, the analog signal from a stereo to a subamp varies in Volts, not much in ampere. So the coding to make the Arduino figure out what to do with it, how to set different levels so that it can translate that to PWN levels. Preferably it can regulate seamlessly, not just on and off, but everything in between as well. And how to do this with varying sound levels, where i presume the volts will go up. Thinking of sampling the highest and lowest voltage x times a second and setting 255 levels, representing PWM levels. Coding?

  • Voltage of the LEDs: The strips require 12 v and are RGB, so they can change in colour. But, i will have to use a voltageregulator (considering this atm), but wont this interfere with the PWM? Or am i just ignorant here hahaha.

  • COLOURSSSS!: These beauties can change colours and comes with predefined programs like Flash, Strobe and such, in the remote. Anyone knows how i might control those things? I get the, pulse defines the brightness levels in PWM, but colours... The "Getting started" book doesnt cover that.
    The LEDs comes with this power supply i suspect has a controller unit in it, think i will take that thing apart, but i dont think i can figure much out anyways.

That is all for now, any help what so ever is very much appreciated, from tutorials to whatever. Has anyone done anything like this before? Or knows any good guides i can use? The coding bit is something i really need to work with, as i am fairly green on this.

Will post results, if i get some!

Thanks in advance!

  • Input signal and coding: If im not mistaken, the analog signal from a stereo to a subamp varies in Volts, not much in ampere.

Yes, you'll want to detect the voltage. The signal into a power amp is approximately [u]line level[/u], depending on the particular head unit and on the loudness.

The output from your soundcard is also approximately line level so you can use that for testing & development.

FYI - The relationship between Voltage, Current (Amperage) and resistance is described by [u]Ohm's Law[/u] (higher voltage = more current, lower resistance = more current). Resistance (or impedance) is the resistance to current flow.

Thinking of sampling the highest and lowest voltage x times a second and setting 255 levels, representing PWM levels. Coding?

You can do that, but audio signals are AC which means that even with a constant tone, the voltage crosses-through zero twice per cycle and is negative half the time. There are (at least) two ways of dealing with the negative half of the waveform. You can bias the input or you can use a [u]peak detector circuit[/u].

I use a peak detector for a couple of reasons... I only have to sample the "loudness" about 10 times per second instead of thousands of times per second when you sample the audio waveform. And, my software can automatically switch to the 1.1V ADC reference when the signal level is low. (You can't use the 1.1V reference when the input is biased at 2.5V.) The downsides to a peak detector are that it's a more complicated circuit and the op-amp requires positive and negative supply voltages.

Once you've got your bias circuit (or peak detector) set up, you can run the [u]Analog Read Serial Example[/u] to see what kind of readings you get form the sub amp signal.

Typically, you'd trigger the lights based on the peaks or the short-term average. Depending on the particular effect, I use both. For example, I've got a VU meter effect that works from the peaks and I've got chase effects where the speed is based on the average volume.

I use a "trick" where I use an array to hold a 20-second moving-average array (see the Smoothing Example). I can use the average from that array, or the peak as a reference and my lighting effects automatically adjust/re-calibrate to changes in volume.

  • Voltage of the LEDs: The strips require 12 v and are RGB, so they can change in colour. But, i will have to use a voltageregulator (considering this atm), but wont this interfere with the PWM? Or am i just ignorant here hahaha.

No. Not a regulator. You can use a MOSFET or transistor to control the higher voltage & current that the Arduino cannot directly supply. Either of these devices will "pass through" the PWM. You'lll need at least one MOSFET/transistor for each "channel". i.e. You need three to control an RGB strip.

  • COLOURSSSS!: These beauties can change colours and comes with predefined programs like Flash, Strobe and such, in the remote. Anyone knows how i might control those things?

It's mostly going to be if-statements and probably the map() function for PWM brightness. And, it's really up to your imagination to take the loudness & loudness changes and do whatever you want. i.e. You can randomly change colors (or fade colors) while flashing to the beat-loudness, or you could make blue respond to quiet sounds and red for loud sounds, etc.

There are also hardware/software techniques for making different colors respond to different frequency-bands (but you couldn't use the subwoofer channel because there are no upper or mid frequencies.)

Thanks aloooot, helped me immensly!!

Yes, you’ll want to detect the voltage. The signal into a power amp is approximately line level, depending on the particular head unit and on the loudness.

The output from your soundcard is also approximately line level so you can use that for testing & development.

You can do that, but audio signals are AC which means that even with a constant tone, the voltage crosses-through zero twice per cycle and is negative half the time. There are (at least) two ways of dealing with the negative half of the waveform. You can bias the input or you can use a peak detector circuit.

I think i will be going for the bias one. But do i need the amplifier part? In that instructable she used a mic, but line is much stronger, and if i do, cant i just use a RIAA amp or cheap headphone amp? The bias part to make the amplitude 2,5V, to me, seem to be the two resistors and capacitor.

No. Not a regulator. You can use a MOSFET or transistor to control the higher voltage & current that the Arduino cannot directly supply. Either of these devices will “pass through” the PWM. You’lll need at least one MOSFET/transistor for each “channel”. i.e. You need three to control an RGB strip.

Ofc, ofc, transistor, not regulator. Well, those are hard to get hold of, but i found a BD233 NPN transistor who can max out 25W. One LED strip uses 24 W, would this transistor be fine? Still trying to wrap my head around how to set up the transistor correctly, but im getting there.

There are also hardware/software techniques for making different colors respond to different frequency-bands (but you couldn’t use the subwoofer channel because there are no upper or mid frequencies

Is this hard to do? Because i dont see much problem just using the original source instead of the subchannel (i.e. a 3,5 mm aux plug).

Again, thanks!!!