1
\$\begingroup\$

I'm working on school project where I need to control LED strip brightness with audio input...

The stereo signal is playing some music on left channel and LED is suppose to react to generated 1khz tone on right channel. Audio signal is far to low to work so I would ned some amplifier... I've tried to do it with LM358 but I couldn't find any working schematics.

I have some basic knowledge about circuits, but not in this area. Any provided schematic is welcome.

Here is a sample of my music. So, the LED should have fade levels as shown on right channel

EDIT:

Here is a picture of circuit that acts like this.

I know that this circuit is not like it should be, but hey, at least some result. All I need is some more 'amplification'. So to be clear, I don't think I need filtering because the tone is stable 1khz and all it maters is strength of it.

*I only use 5V supply from Arduino on video Circuit that works like on video.

\$\endgroup\$
3
  • \$\begingroup\$ Hi, I suggest you read this, and then go back and flesh out your question. \$\endgroup\$
    – Dampmaskin
    Mar 19, 2020 at 16:25
  • \$\begingroup\$ Thank you for your notice but all I need is some help with this circuitry. \$\endgroup\$ Mar 19, 2020 at 21:32
  • \$\begingroup\$ your transistors are upside down, and your 358 is operating as a comparator rather than an amplifier. \$\endgroup\$
    – Hearth
    Mar 25, 2020 at 16:41

1 Answer 1

1
\$\begingroup\$

What you need is the following:

  1. Filtering? (only if there's more than just the 1 kHz tone on the right channel)
  2. A volume detector, which usually consists of
    1. a amplifying rectifier and
    2. an averaging filter
  3. Digitization of the volume signal
  4. Software to control the LED strip

Volume detector

That starts with a rectifier, followed by a low-pass filter.

Rectifier

i.e. a combination of rectifier and some kind of amplification.

Luckily, that's simple. Look for "precision rectifier opamp circuit". Don't use an old opamp (If it has 741 in its name, use a different one).

The result would roughly look like this (image from Analog Devices' excellent wiki):

Precision rectifier

Connect your right channel with a capacitor to CA-V.

The amplification of this circuit is \$-\frac{R_2}{R_1}\$, so pick something like 10 times the resistance for R2 than for R1. These resistors can have pretty large values; use something like 10 kΩ or 100 kΩ!

The two diodes can be of many types, but cheap small signal diodes like the 1N4148 will do.

The output of this will be only the positive half of your input wave. Why's that useful?

The original signal had an average of 0V (when you think of it, the sine waves have as much "area covered" above the x-axis as below), no matter what the amplitude was.

The rectified signal now has an average that is proportional to the amplitude of your 1 kHz wave!

Low-pass filter

Now, we "just" have to find the average of the rectified signal. A low-pass filter is quite like an average – it smooths out fast-changing signals.

In case of your signal, we even know how fast the change is: we're cutting of half of the wave, so the lowest frequency in there is the average at 0 Hz, and the next higher frequency in the signal is at 2 kHz. (a bit of math hidden here – ask your teacher as to why I know that it's at 2 kHz to make them refresh a bit of theory.)

Anyways, so for things to be sensible, we'd want to build a filter that lets through signal below some frequency, and cuts it off above that. We call that the cutoff frequency of a low-pass filter. OK, in our case, since you want to be able to observe things with the human eye, 100 Hz sounds like a good cutoff frequency. Can't see faster, and it's above 0 Hz and below 2 kHz.

So, build a RC low-pass filter and attachit to the output of our amplifying rectifier. Use relatively large values of resistors again – 10 kΩ would be a good start.

Digital processing

No matter what we do, your LED strip is a digital device.

So, we need a digital controller.

A microcontroller is just that, and I don't see a way of doing this without one.

Many microcontrollers come with an Analog-to-Digital Converter (ADC). If we run the ADC at twice the highest frequency in our signal, then we get something that represents our analog signal as digital numbers.

So, let's use a ADC sampling rate of 200 Hz. This means your ADC looks at the analog input every 1/200 s, and gives you a digital number. For a modern microcontroller, that's very slow, so you have plenty of time to do math with these numbers in microcontroller software.

Then, you'll want to multiply the numbers so that they fall in a useful range for you, then you'll want to calculate what that means (you never specified that in your question) for the LED control, and you send out the right commands based on that to your LEDs. Done!

Of course, you'll need to somehow connect to your LED strip. How you do that depends on the LED strip, and on your microcontroller.

Conclusion

Aside from the analog circuitry parts, this is a project that involves programming a microcontroller to both do a bit of digital signal processing and control of external hardware.

To me, that sounds ambitious as a school project. Start small. Start with the rectifier. Verify that works. Then add the filter. Verify that works. Then, learn how to use the ADC on your microcontroller. That takes time.

\$\endgroup\$
5
  • \$\begingroup\$ Thank you so much for the explanation! I believe this wouldn't work, but could you explain to me why it would not work to connect audio output from amplifying rectifier to NPN transistor? Also, I came to idea to use something as PAM8403 to amplify my signal as there is output to 3W speaker and connect it to transistor (also, some NPN) base. \$\endgroup\$ Mar 19, 2020 at 18:00
  • \$\begingroup\$ what would the NPN transistor do? I don't see what this has to do with your problem, to be honest? \$\endgroup\$ Mar 19, 2020 at 18:24
  • \$\begingroup\$ Ohe way of doing it without a microcontroller is to use the op-amp for just a (slow) peak detection, and create a PWM generator with a sawtooth generator and a comparator. It's possible to get something working ( though not very linearly) with just one op-amp and a 555. Myself I'd use the microcontroller, but it depends on what the learning aim is for this exercise. \$\endgroup\$
    – Phil G
    Mar 19, 2020 at 21:04
  • \$\begingroup\$ It's about final work... See for edit about thing with NPN transistor. I have quite experience with Atmel's (Arduino's) atmega328, but I'm not sure I know how to pull this of with microcontroller so I've concentrated project to only hardware solution. \$\endgroup\$ Mar 19, 2020 at 21:38
  • \$\begingroup\$ If you already know how to use a microcontroller, that's CLEARLY the way to go \$\endgroup\$ Mar 20, 2020 at 8:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.