Transistors as Switch and Amp to control LED strip

I am controlling an LED strip based on audio input from my phone. I am having some good results, but not exactly what I want, and my ignorance of transistors is holding me back (I'm a Mech E major rather than electrical).

I have my phone connected to an amplifier which then outputs an AC audio signal through a Bridge rectifier and then that DC signal is sent through an NPN transistor (TIP 121) acting as a switch to control an LED strip. I've got the lights to choreograph to music and it looks great, however, it only works when the volume is very loud. As I increase the volume, the LED strip gets brighter, and as I decrease it, the LED dims.

My first question is why does this happen? I have the strip connected to 6V so shouldn't the input from the amplifier to the transistor only switch on and off the 6V supply?

And if i want the lights to work at low volume (when there is too of low current from the amp to switch the transistor), can I add a second transistor to act as an amplifier (based on a common collector/emitter follower circuit)? Should that second transistor go before or after the bridge rectifier?

Could I even just feed the AC input straight into the analog pins of an Arduino, and control the transistor and LED strip from a digital output pin (being mindful of max voltage inputs). Circuit diagram is attached. Thanks.

If you wanted to do this completely in hardware (no software) I'd suggest a [u]comparator[/u]. A comparator turns-on (the output goes high) when the input is higher than reference. You can use a low reference to make it very-sensitive and/or use a potentiometer to make the reference variable.

Then you could follow that with a [u]555 one-shot[/u] to hold the LEDs on for 1/10th of a second or so every time it's triggered. (Then drive the transistor with the 555.)

With the 555 holding the LED on for a short period of time, you can skip the rectification and simply ignore the negative-half of the audio signal.

Could I even just feed the AC input straight into the analog pins of an Arduino, and control the transistor and LED strip from a digital output pin (being mindful of max voltage inputs). Circuit diagram is attached.

The Arduino can be damaged by negative voltages or by voltages greater than +5V. And/or the Arduino can "damage" (distort) the audio signal.

The "standard approach" is to bias the Arduino input at half the supply voltage with two equal-value resistors, then use a capacitor to block the bias from your audio circuit ([u]example[/u]). With the input biased at 2.5V, silence will read about 512 on the ADC. Quiet sounds will deviate slightly above and below that, and louder sounds will deviate more. You can subtract-out the bias in software. The bias circuit usually works well with line-level or headphone-level signals. If you want to use the "speaker output" from a powerful amplifer you'd probably need some attenuation and protection.

If you are worried about over-voltaging the Arduino you can add a [u]protection circuit[/u]. Or, you can use the protection circuit without the bias and ignore the negative half of the waveform.

I use a [u]Peak Detector[/u] (AKA "Envelope Follower"). It puts-out a varying DC voltage that matches the peak of the audio signal. But, op-amp circuits generally require positive & negative power supplies so that adds to the complexity.

Note that (if you're not using a peak detector) you are [u]sampling a waveform[/u] that's continuously varying (even with a constant tone) and it's crossing-through zero twice per cycle. So unless you "do something" the LED can't be constantly-on and you won't perceive full-brightness.

A 20Hz wave (generally the lowest audio frequency) has a period of 50 milliseconds (or 25ms per half-cycle). So, there a couple of things you can do... You can sample for ~50ms and save the peak, or sample several times over the 50ms period and calculate the RMS, or the average of the absolute values, or the average of the positive values.

So... Once you are reading the "loudness", here's the "World's Simplest Lighting Effect":
Make an array to calculate the [u]Moving Average[/u]. I save a one sample per second and save it in a 20-element array to get a 20-second moving average, but you can adjust that if you wish.

Then in a fast-loop (or maybe 10 times per second) read the "loudness" and compare it with the average. When it's above average turn the LED strip on, and when it's below average, turn it off. The light will be on half the time and off half the time for lots of "lighting action" and it will self-adjust to loud & quiet music.


The diodes in your bridge rectifier don't start to conduct until you have about 1/2 volt across them. And, in the bridge configuration you've always got two in series so nothing happens until you get over 1V. Then it takes another 0.5 to 0.7V to turn-on the transistor. That's why nothing is happening 'till you get "loud".

You are not necessarily turning the transistor all the way on and it will be partially-on due to the analog wave. Turning it partially-on can overheat it.

Your capacitor is on the wrong side of the resistor and it can potentially affect the audio signal.


P.S.
In a hardware-only design you could use a peak-detector in front of the comparator and the LED would stay-on long enough to see it and to get full-brightness without the 555 timer.

You could also use two peak detectors, one faster than the other. The slower one could be used for the comparator reference (like an average of the peaks) and the faster one as the signal input. (You'd have to put some attenuation on the reference to get more of an "average" reference level that's below the actual peaks.)

Hi,
Can you explain what you want the LEDs to do with the music?
Flash/pulse with the bass?
Flash/pulse with music peaks?
Fade with music volume?
OPs circuit;


I presume the negative output from the bridge is to the same ground as the transistor?

The 100uF will have an effect on the response of the LEDs,
What is the output level, volts, of the amplifier?
Where are you getting the output for the bridge from?

Thanks.. Tom... :slight_smile:

What current do the LEDs take?

There should be a resistor before the 100uF cap so that the amplifier isn't seeing a short-circuit load.
10 ohms is probably enough to take the strain from the amp.

The rectifier should be a full-wave rectifier (two diodes), not a bridge.

Increase the cap to a higher value may cure the flicker.

Change the 1k resistor to a lower value, try 100 ohms, then the transistor is more likely
to saturate properly.

Wow thank you all for such great feedback. This is something that has been on hold for a while because of a busy schedule, but I am getting back into it.

TomGeorge,

I want the LEDs to flash with music peaks. Everything has the same ground. I've used a DMM and an arduino to check the voltage. The output of the amplifier is 0 V until it's about 3/4 of the way up. This is very loud and I'll start to see 1-3V. When it is on max volume (very, very loud), Ill see up to about 12 V. I'm not quite sure I understand your last question, the output from the bridge connector is the new DC signal from the amp.

MarkT,

The wall plug for the LEDs says the output is 6V, 1000 mA. I've lowered the resistor and moved the capacitor to behind the resistor. Isn't a full wave rectifier the same as a bridge (4 diodes)? It would be more beneficial to have a full wave rather than half wave, correct?

DVDdoug,

Thanks for such great suggestions. I already have a 555 and plan on getting a comparator (already have two sound sensor comparators). I think I'll stick to a hardware only design at first, and then possibly throw in an arduino to the circuit.

My current goal is to have the lights blink at a normal listening level for a quiet room (pretty low volume on the amp). Another idea I'm interested in is ditching the amp and speakers and see if I can have the LEDs blink based directly on the aux output of my iPhone. Since my amplifier at low volume and my iPhone output both produce very low voltages, should I try to place in an op amp or transistor as an amplifier so that the signal is amplified and can then switch on/off another transistor to control lights?

Again, sorry for the late reply and any help appreciated.

Thanks for such great suggestions. I already have a 555 and plan on getting a comparator (already have two sound sensor comparators)...

…Since my amplifier at low volume and my iPhone output both produce very low voltages, should I try to place in an op amp or transistor as an amplifier so that the signal is amplified and can then switch on/off another transistor to control lights?

You can set the comparator threshold anywhere you like so it can work from a headphone or line-level output. And, you'll probably want to add a potentiometer so you an adjust the sensitivity (threshold).

A long-long time ago I made something with two peak detectors and a comparator. One of the peak detectors had a bigger capacitor to make it slower. By using the slower one to get the threshold (maybe with a voltage divider?) With that, I had an automatic sensitivity adjustment. I don't remember all of the details, but that was the concept and it worked.

Now, I do that kind of thing in software. See World's Simplest Effect.

What you are trying to make is called a "Color Organ" and was very popular in the '60s.
The English call them "Sound to Light" generators (I think).
If you plan to use you iPhone audio jack you should start by learning something about Line Level Audio specs

There's a gazilion color organ schematics online ranging from simple transistor bandpass filters to complex active filters (like I used to make a 10 band Graphic Equalizer to use as the 'front end" of my color organ).

There is also the method using the graphic equalizer chip