Basic schematic to make led strip lights react to music?

I have this type of led strip which is supposedly very easily programmable with Arduino:

https://www.amazon.com/gp/product/B01533H3CG/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1

I want to do some simple prototyping to make the led's flash on and off based on sound levels.

Can anyone give me a breakdown of basic components? Also, what sort of code would I run to make the lights flash brighter or softer based on intensity of music?

Thank you!!

For audio input you need some sound analyser module, that outputs the volume in total or split into multiple frequency bands. Then map the amplitude values into some display pattern or effect.

For a simple level indicator an audio (pre-)amplifier and a peak detector (hardware or software) is sufficient.
Eventually you can use the Arduino FFT library to analyse the sound.

I would use one of these chips:-
http://tronixstuff.com/2013/01/31/tutorial-arduino-and-the-msgeq7-spectrum-analyzer/

If you just want to use it like a normal VU meter, or if you just want to control the brightness of the LEDs based on the amplitude, you can use a circuit like this:
Arduino VU meter.png

This can only be used if the audio input signal is less than 5V peak-to-peak (2.5V peak), otherwise you may kill the Arduino. Most normal audio sources like a computer or a smartphone are safe, but you have to be careful when using the output of a headphone amplifier or a professional audio mixer, for example. The last thing you want to do is connecting it directly to the speaker output of an amplifier. If you want to protect the Arduino, you could use a clamping diode to ground, and a 5.1V zener.

The first thing you have to do, before connecting an audio source, is uploading the AnalogReadSerial example, and setting the potentiometer so that it reads 512.

This is the code I use to drive 8 LEDs connected to a shift register like a VU meter. It can be easily adapted to use it with your LED strips.

#include <math.h> // for log10() function 

const float Vref = 0.775; /* https://en.wikipedia.org/wiki/Decibel#Voltage standard: 0.775V = sqrt(600Ω · 1mW) = 0dBm = 0dBu (reference for professional gear) 
                           * Most professional gear uses +4dBu = 1.228V (professional line level)
                           * The consumer audio reference is 0dBV = 1V
                           * Most consumer gear uses -10dBV = 0.316V (consumer line level)
                           */
const int thresholds[8] = { -20, -15, -10, -7, -5, -3, 0, 3 }; // what LED should turn on at what amplitude
const float decay = 0.5; // dB per refresh (higher = more responsive, lower = smoother)

const int latchPin = 8;  //Pin connected to ST_CP of 74HC595
const int clockPin = 13; //Pin connected to SH_CP of 74HC595
const int dataPin = 11;  //Pin connected to DS of 74HC595

const float Valref = 1023.0 * Vref / 5.0; // an analog value of 1023 is equivalent with 5V, so convert the reference voltage to an analog value.

void setup() {
  Serial.begin(115200);
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
}

float dBOld = 4; // if you set it to anything > thresholds[7], you get a nice startup animation :)

void loop() {
  uint32_t AmplitudeValue = 0;
  for (int i = 0; i < 128; i++) { // average of 128 readings
    int centered = analogRead(A0) - 512; // don't use other functions or operators inside of abs()
    AmplitudeValue = AmplitudeValue + abs(centered); // sound is AC, and an amplitude of 0 gives an analog value of 512
  }
  AmplitudeValue /= 128;

  float dB = AmplitudeValue > 0 ? 20 * log10(AmplitudeValue / Valref) : -999; // convert to logarithmic scale (logarithms are only defined for strictly positive numbers) https://en.wikipedia.org/wiki/Decibel#Field_quantities_and_root-power_quantities
  dB = dB < (dBOld - decay) ? dBOld - decay : dB; // meter falls down smoothly
  dBOld = dB;
  
  Serial.print(AmplitudeValue);
  Serial.print('\t');
  Serial.print(dB);
  Serial.println(" dB");
  
  byte shiftVal = dBToVU(dB);
  digitalWrite(latchPin, LOW); 
  shiftOut(dataPin, clockPin, MSBFIRST, shiftVal); // write to shift register
  digitalWrite(latchPin, HIGH);
}

byte dBToVU(float value) {
  byte result = 0;
  for (int i = 0; i < 8; i++) {
    if (value > thresholds[i]) {
      result |= 1 << i;
    }
  }
  return result;
}

What the code does is basically calculating the average voltage (VRMS) then converting it to dBm (or dBV, depending on the setting) and then limiting the decay. You could probably add a more advanced peak detector if you wanted to, but it does a pretty good job displaying the level.


In blue, you can see the VRMS, and the output in orange.

If you want a real spectrum analyzer, like this, you'll need a chip like the MSGEQ7 mentioned by Grumpy_Mike, or you could use the same circuit as above, and do all processing on the Arduino. In the case of audio, a Constant-Q Transform would be more appropriate than an ordinary FFT, since our hearing is logarithmic (a FFT would work as well, but you'd need more frequency bins to get the same result).
The latter option is much easier and cheaper on the hardware side of things, but the software part is quite hard and involves some difficult mathematics.

Pieter

This can only be used if the audio input signal is less than 5V peak-to-peak (2.5V peak), otherwise you may kill the Arduino

That is only true if the pot is exactly in the middle. As the pot gets closer to one end or other the maximum audio you can use drops.

Rather than use a loop to get an average, I've used a running average trick :

ave += input;
ave *= (1-1/aveLen);
ave1 = ave/(aveLen-1);

where aveLen is the number of samples over which to average... ave1 is the smoothed output.

regards

Allan.

Grumpy_Mike:
That is only true if the pot is exactly in the middle. As the pot gets closer to one end or other the maximum audio you can use drops.

PieterP:
The first thing you have to do, before connecting an audio source, is uploading the AnalogReadSerial example, and setting the potentiometer so that it reads 512.

allanhurst:
Rather than use a loop to get an average, I've used a running average trick :

ave += input;

ave *= (1-1/aveLen);
    ave1 = ave/(aveLen-1);



where aveLen is the number of samples over which to average... ave1 is the smoothed output.

Great trick, thanks!

Thank you to all!! And Pieter, your detailed advice is exceedingly helpful. I was indeed hoping to make the led's brighter or dimmer based on amplitude, and also was not planning to connect speaker output directly to arduino. I am in the process of testing, and right now I'm trying a pre-written code that works with parallax sound sensor. Hoping I can get this to work, and it would be a good start for doing more complex things.

Thanks again, I appreciate it:))

A sound module will just have a microphone on it to detect "loudness" without any discrimination.
Just note that the response time on those LEDs aren't incredibly fast, and you haven't made it clear what you want the response to be. You can use the sound input to vary the power going into the strip to simply have reactive brightness. But then that's a bit of a waste of the 'smart'ness of those LEDs. Any dumb strip at a fraction of the cost would have worked.