MSGEQ7 not reacting to Audio

Schematic I'm following:

Picture of breadboard circuit:

Quick explanation of circuit:
Ignore the transistor stuff on the bottom left. That's what's going to be attached to the LED strip. (Yes, I'm aware of all the information on this sort of project on the internet, especially this forum. Yes, I've done the research and tried most resources. Yes, I still can't solve my problem.) I know I'm not supposed to put that part of the circuit in until after the MSGEQ7 is functional, but I had nothing to do whilst waiting for the MSGEQ7 to arrive.

Pin 1: Has the .1uF capacitor and then goes to ground via orange cable.

Pin 2: Straight to ground via another orange cable.

Pin 3: Goes to A0 of my Arduino MEGA.

Pin 4: Goes to PWM 4 on the Arduino.

Pin 5: Goes to an Audio Cord (Aux Cord) that was cut and the left, right, and common grounds were wrapped around a wire and then attached to the breadboard.

(I feel iffy doing this, is this a viable way of passing the audio to the breadboard?
I have one of these:

with another Aux cord if that's more viable.)

The Audio goes through a 22K resistor, and the .01uF capacitor to the fifth pin.

Pin 6: Has the .1uF capacitor with a wire taking it to ground.

Pin 7: Has a wire going to pin number two.

Pin 8: Two 100k resistors in series going from pin one to a 5V connection. (Supplied from the Arduino Mega. Arduino is connected to 12V power adapter.) I also have the 33pF capacitor attached to ground.

The Arduino's code is:

int analogPin = 0; // MSGEQ7 OUT
int strobePin = 4; // MSGEQ7 STROBE
int resetPin = 2; // MSGEQ7 RESET
int spectrumValue[7];

// MSGEQ7 OUT pin produces values around 50-80
// when the re is no input, so use this value to
// filter out a lot of the noise.
int filterValue = 70;

// LED pin connected to the PWM pins on the Arduino
int ledPinPower = 11;

void setup()
{
  Serial.begin(9600);
  // Read from MSGEQ7 OUT
  pinMode(analogPin, INPUT);
  // Write to MSGEQ7 STROBE and RESET
  pinMode(strobePin, OUTPUT);
  pinMode(resetPin, OUTPUT);

  // Set analogPin's reference voltage
  analogReference(DEFAULT); // 5V

  // Set startup values for pins
  digitalWrite(resetPin, LOW);
  digitalWrite(strobePin, HIGH);
}

void loop()
{
  // Set reset pin low to enable strobe
  digitalWrite(resetPin, HIGH);
  digitalWrite(resetPin, LOW);

  // Get all 7 spectrum values from the MSGEQ7
  for (int i = 0; i < 7; i++)
  {
    digitalWrite(strobePin, LOW);
    delayMicroseconds(30); // Allow output to settle

    spectrumValue[i] = analogRead(analogPin);

    // Constrain any value above 1023 or below filterValue
    spectrumValue[i] = constrain(spectrumValue[i], filterValue, 1023);


    // Remap the value to a number between 0 and 255
    spectrumValue[i] = map(spectrumValue[i], filterValue, 1023, 0, 255);

    // Remove serial stuff after debugging
    Serial.print(spectrumValue[i]);
    Serial.print(" ");
    digitalWrite(strobePin, HIGH);
  }

  Serial.println();

  // Write the PWM values to the LEDs
  analogWrite(ledPinPower, spectrumValue[4]);
}

I just bought the MSGEQ7 off of Sparkfun, so hopefully it isn't a dud. I have two more, but I want to cross off all other options before I try the next one. The audio cord is connected to my phone, but I have tried with my laptop as well.

My issue consists of the MSGEQ7 simply not responding to my audio when played. Currently, my output has a bunch of random numbers in the serial monitor. So, at-least the MSGEQ7 is outputting something.

Serial Monitor:

My goal is to have this properly reacting to Audio. My thoughts are that the issues can lie with the MSGEQ7, the Audio coming in, and possibly, hopefully not, the code.

Also, I've seen a lot of posts about op-amps and what not, but I read that the MSGEQ7 has it's own 20dB gain. Is this enough for the Audio to be input properly?

Also, yes, my capacitors are ceramic.

Let me know if I missed anything, I skipped the whole hand-made schematic drawing because I'm following such a small and specific one. I'd gladly draw one, if requested. I can provide additional information if you have questions.

Thank-you for your time,
Amaury.

[EDIT]
The furthest two orange cables on the breadboard are the left channel from the audio cable and the ground for the audio cable. The audio appears to be in the wrong row from the resistor, but I can assure you this is just due to my bad camera angle! Sorry about that if it confused anyone.

[EDIT2]
I just realized that when I was working with my circuit and cleaning it up, I forgot to add the power cable to Pin one. I've thus added another wire going to the 5V supplied from the Arduino to Pin One. Both the serial monitor and picture of the circuit have been updated. Sorry for the confusion, once again!

Pin 5: Goes to an Audio Cord (Aux Cord) that was cut and the left, right, and common grounds were wrapped around a wire and then attached to the breadboard.

Bad idea on three counts.

  1. You are shorting two outputs together, expect to damage the audio source.
  2. You need a capacitor between pin 5 and the audio input.
  3. You are not making a good connection like that, connections need to be soldered.

I don't think you mean that the common ground is connected to the signals but that is how it reads.

Grumpy_Mike:
Bad idea on three counts.

  1. You are shorting two outputs together, expect to damage the audio source.
  2. You need a capacitor between pin 5 and the audio input.
  3. You are not making a good connection like that, connections need to be soldered.

I don't think you mean that the common ground is connected to the signals but that is how it reads.

Alright, so I'll be using the audio jack from the RadioShack. My question before I try that is, there are two prongs and then the big metal backing that the audio jack clips into.

(https://www.radioshack.com/products/radioshack-1-4-mono-panel-mount-audio-jack-2-pack)

Which is left, right, and common?

I'm sorry if this sounds simple, I've been confused and haven't been able to find an answer if the metal back is negative or not.

[EDIT]
FYI, I didn't connect all three to one individual wire. My apologies for the confusing explanation. Each one was connected to an individual wire that I placed on the breadboard. I'm switching to the audio jack because you were correct that they provide better connections.

What is your actual circuit? That link just links to the data sheet. How are you connecting it to the Arduino?

Pin 6 should be connected to the audio's common ground, with Pin 2 to the Arduino's ground.

Which is left, right, and common?

The big metal one connects the tip and the common ground is the lowest ( closest to the chassis mounting ).
If you only have one chip you should combine the audio by connecting then together through a 1K resistor on each channel.

The problem with you photo is you can't tell which way round the chip is.

Grumpy_Mike:
What is your actual circuit? That link just links to the data sheet. How are you connecting it to the Arduino?

Pin 6 should be connected to the audio's common ground, with Pin 2 to the Arduino's ground.
The big metal one connects the tip and the common ground is the lowest ( closest to the chassis mounting ).
If you only have one chip you should combine the audio by connecting then together through a 1K resistor on each channel.

The problem with you photo is you can't tell which way round the chip is.

The chip connects to the Arduino multiple ways.
Pin three goes A0 on the Arduino. Pin four goes to PWM 4 on the Arduino. Pin seven goes to two on the Arduino.

I believe that should be correct if pin three is out, four is strobe, and seven is reset.

I have a ground from the Arduino connected to the breadboard, where all the grounds from the Audio + MSGEQ7 are being led to.

The big metal one connects the tip and the common ground is the lowest ( closest to the chassis mounting ).
If you only have one chip you should combine the audio by connecting then together through a 1K resistor on each channel.

I went ahead and tried this set-up,

You said that the big one connects to the tip.
I looked up a picture that says the tip is left.
You said that the common ground is the lowest one.
I checked and saw the lower one, so that's ground.
That only leaves right left, which the picture says should be the other clip.

After trying this, it worked!

I'm currently having another issue with powering the LEDs, the circuit I had does not seem to be working as I wanted it to. Basically, I'm looking to design a circuit to use an NPN transistor as a variable resistor that drops 12V to 0V if the PWM of the Arduino is 0V (or 5V is need be) and goes 12V for the opposite.

If you have any ideas, please let me know!

Besides that, thank-you so much!

I'm looking to design a circuit to use an NPN transistor as a variable resistor that drops 12V to 0V if the PWM of the Arduino is 0V (or 5V is need be) and goes 12V for the opposite.

Again we need to see a schematic, but on the face of it that is not how you dim LEDs in a strip. If you were to design such a circuit the transistor would burn up if you had a large number of LEDs.

So how many LEDs?
Schematic about how you want to control them please.

Normally you dim a strip by applying PWM to a transistor or FET.

Grumpy_Mike:
Again we need to see a schematic, but on the face of it that is not how you dim LEDs in a strip. If you were to design such a circuit the transistor would burn up if you had a large number of LEDs.

So how many LEDs?
Schematic about how you want to control them please.

Normally you dim a strip by applying PWM to a transistor or FET.

My apologies, I didn't have a schematic, so I created one on both Fritzing for a visual picture of what I'm doing and other software to show you the schematic.

Fritzing Screenshot:

Schematic Screenshot:


(Created on PartSim, didn't have time to use software like LTSpice)
P.S: The ground to the right, labeled PWM 11, is not a ground pin but the PWM 11 pin on the Arduino. PartSim wouldn't allow me to create a wire without leading it somewhere.

This schematic works in dimming the lights, but it seems to be dimming the lights only when the numbers on the MSGEQ7 spike. Currently, that's the inverse of my goal. I wish for the lights to stay at a certain dimness, and spike when the numbers on the MSGEQ7 spike. Is this something fixable with the code? (I would assume so, but just making sure) Or does the goal require a circuit change?

The product link:
Amazon Link

I couldn't find the datasheet for that specific RGB strip, but I found a datasheet that includes the schematic of the RGB strips. Let me know if this provides what you need.
Datasheet

Just to clear any confusion, I'd like to restate my goal.

Currently, the function of the LED strip is to drop in brightness if the MSGEQ7 spikes. This means that if no music is playing, the LEDs are on. If music is playing, the LEDs are indeed pulsing, but they are dimming to the spikes, not becoming brighter due to the spikes.

My intended function includes:
I want to have the LEDs idle at a certain brightness if no music is playing. Once the music is playing, I want the LEDs to become dim. Note, this is not the same brightness as if no music were playing. Once the LEDs become dimmer, I want that dimness to act as a sort of baseline for when the music becomes "quiet" in-between songs, if there's no beat going on, etc. Once the MSGEQ7 begins to spike, I want the lights to get brighter.

I apologize if I'm over-explaining this.
Here's a video of a project with similar desired functions:
Youtube Link
The beat detection isn't as smooth as I'd like it to be, but the same logic is applied. Beat spikes, so does brightness.

If you have any other questions let me know, I'd be glad to answer them.

Furthermore, I'd like to say thank-you for your help thus far.

Thanks,
Amaury

I want to have the LEDs idle at a certain brightness if no music is playing.

You do that very simply in software, it is not something you should consider in software.
Suppose you have an 8 bit value you want to apply to the PWM you use:-

analogWrite(pin,value); // for increasing value = increasing brightness
or
analogWrite(pin,255-value); // for increasing value = decreasing brightness

There is no way that schematic can work if you have truly wired it up like that.
You need the PWM pin to connect to a 1K resistor with the other end connected to the base of the transistor. Then the collector connects to the LED -ve, with the emitter to ground of both the Arduino and the 12V supply. ( that last bit is all that is right with your circuit ).

Your transistor is wired wrong...

[u]Here is a driver circuit[/u]. The LED goes in place of the solenoid, and you can leave-out the diode. (That's assuming you've got a 12V LED strip.)

In a transistor the (usually larger) collector-emitter current is controlled/switched by the (usually smaller) base-emitter current. So your load goes in series with the emitter or collector and you can think of the base as the "input".

And because of the way transistors work, the load usually goes between positive supply voltage and the collector of an NPN transistor (so we are switching the ground/low connection).

I know I'm not supposed to put that part of the circuit in until after the MSGEQ7 is functional, but I had nothing to do whilst waiting for the MSGEQ7 to arrive.

It doesn't matter what you do first, but you should do one thing at a time and if you're going to build the LED circuit first you should test & debug it (with a simple blink or dim program) before adding the MSGEQ7. (And, you can test your blink/dim program with a regular LED & resistor before connecting the transistor & LED strip.)

In response to both of you,

I've constructed another circuit, if you can review provide feedback, I'd gladly appreciate it.

The LED goes in place of the solenoid, and you can leave-out the diode. (That's assuming you've got a 12V LED strip.)

I just realized that although I've been working with a 12V power supply, I plan to move it to 24V. (Longer LED strips) Would I have to add the diode between the power supply and the positive side of the LED

That circuit will short out the 12V supply and the transistor will melt.

Would I have to add the diode between the power supply and the positive side of the LED

No.

Grumpy_Mike:
That circuit will short out the 12V supply and the transistor will melt.

I'm confused as to where the 12V power supply connects in. Both schematics don't really help me determine where to put the positive of the 12V supply. Could you possibly guide me with this? Furthermore, I don't think I've chosen the right transistor in the schematic. I've been using a MOSFET.

[EDIT]
My latest attempt, I've been testing them out with the PartSim simulator. I don't think this is one is correct either but I'd like to post progress.

P.S: This is the datasheet for the transistor I'm using.

No. In both circuits you have the transistor/MOSFET directly between +12V and ground. When the transistor/MOSFET turns-on, current flows directly through the transistor/MOSFET, essentially shorting-out the power supply, and "pulling" down the power supply voltage to (nearly) zero and drawing excess current. That can fry the power supply and/or the transistor/MOSFET.

The LED is also connected directly between 12V and ground, so it's always on (at least until the transistor/MOSFET shorts-out the power supply).

The LED needs to be in series with the transistor/MOSFET, so that any current that goes through the LED has to go through the transistor/MOSFET too. With the two devices in series, when the transistor/MOSFET turns off no current flows through it so no current can flow through the LED either.

...I gave you a link to a driver circuit. Did you miss that?

Read reply #7 again and ask about what you don't understand.

I'm going to post my logic throughout following your instructions, in hopes that one of you can catch my mistake.

Mike,

There is no way that schematic can work if you have truly wired it up like that.
You need the PWM pin to connect to a 1K resistor with the other end connected to the base of the transistor. Then the collector connects to the LED -ve, with the emitter to ground of both the Arduino and the 12V supply. ( that last bit is all that is right with your circuit ).

You used terms like base, emitter, collector, etc. I have a MOSFET. This means that I'm working with gate, drain, and source, correct?

I attached PWM channel to a 1k resistor and then to the gate (Left pin, facing forward) of the MOSFET.
You stated that the collector connects to the LED -ve. This means that the LED -ve is connected to the drain of the MOSFET. Got it. Finally, you said the emitter goes to the ground of the Arduino and the 12V supply.

I now have a MOSFET with a PWM connected to a resistor that leads to the gate. The negative side of the LED goes to the drain. The source goes to ground which leads to a ground pin on the Arduino.

Where I lay confused:
Where does the positive of the LED go? Where does the positive of the power supply go? You've only stated where the negatives go.

DVDdoug,

I did see your circuit, but I have roughly the same problem with your circuit as well.

The LED goes in place of the solenoid, and you can leave-out the diode. (That's assuming you've got a 12V LED strip.)

Looking at the picture you posted,
You said the SOLENOID was replaced by the LED. I'm assuming this is L1 on the circuit?

This leaves me with,

The gate of the MOSFET connected to the PWM with a resistor between.

The drain of the MOSFET is connected to the LED (Both positive and negative are connected, with negative facing the MOSFET) and the LED leads to the positive of the 12V.

The source of the MOSFET leads to the Arduino Ground Pin.

Am I missing something? I feel like it's the placement of the LED. Should the negative of the LED be on the other side of the transistor?

Thanks again for your help.

[EDIT]
Posting the schematic where I'm currently at.

[EDIT2]

The schematic posted above seems to be working.
If it's the correct circuit, I have a question.

Does the voltage that the RGB strip receives the controller of the brightness?
Or am i supposed to be doing what I'm doing to the colors of the RGB strip, and not the power?
I don't know if that makes sense, let me know if you have any questions.

You used terms like base, emitter, collector, etc. I have a MOSFET. This means that I'm working with gate, drain, and source, correct?

When I wrote those comments you were still using a bipolar transistor not a FET. The gate resistor needs to be way smaller than a base resistor, only about 130R to keep the peak current down.

Where does the positive of the LED go?

To the +ve of the battery.

Does the voltage that the RGB strip receives the controller of the brightness?

Yes but that is not what you are doing here.
For an RGB strip you will need three FETs wired up like this.

Read about why PWM works here :-http://www.thebox.myzen.co.uk/Tutorial/PWM.html

Grumpy_Mike:
When I wrote those comments you were still using a bipolar transistor not a FET. The gate resistor needs to be way smaller than a base resistor, only about 130R to keep the peak current down.
To the +ve of the battery.
Yes but that is not what you are doing here.
For an RGB strip you will need three FETs wired up like this.

Read about why PWM works here :-http://www.thebox.myzen.co.uk/Tutorial/PWM.html

Yeah, I got it working! Smoothed out some code and I have the LED strip visually displaying bass.

Now, I plan coding the LED strip with a bluetooth transceiver so that I can manipulate the color and frequency being played through my phone. Back to research!

This is what I did with my MSGEQ7 chips :- Danse Macabre on Vimeo

Quick question:
The LED lights seem to pick up audio played through my phone only and not my laptop.
What could possibly cause this to happen? I can provide more information if needed.

Also, what would you suggest to do with the code to prevent the lights from flickering so much?

I provided an updated version of my code:

int analogPin = 0; // MSGEQ7 OUT
int strobePin = 4; // MSGEQ7 STROBE
int resetPin = 2; // MSGEQ7 RESET
int spectrumValue[7];

// MSGEQ7 OUT pin produces values around 50-80
// when the re is no input, so use this value to
// filter out a lot of the noise.
int filterValue = 80;

// LED pin connected to the PWM pins on the Arduino
int ledPinPower = 11;
int ledPinPowerRed = 12;

void setup()
{
  Serial.begin(9600);
  // Read from MSGEQ7 OUT
  pinMode(analogPin, INPUT);
  // Write to MSGEQ7 STROBE and RESET
  pinMode(strobePin, OUTPUT);
  pinMode(resetPin, OUTPUT);

  // Set analogPin's reference voltage
  analogReference(DEFAULT); // 5V

  // Set startup values for pins
  digitalWrite(resetPin, LOW);
  digitalWrite(strobePin, HIGH);
}

void loop()
{
   int number2 = 0;
  // Set reset pin low to enable strobe
  digitalWrite(resetPin, HIGH);
  digitalWrite(resetPin, LOW);

  // Get all 7 spectrum values from the MSGEQ7
  for (int i = 0; i < 7; i++)
  {
    digitalWrite(strobePin, LOW);
    delayMicroseconds(100); // Allow output to settle

    spectrumValue[i] = analogRead(analogPin);

    // Constrain any value above 1023 or below filterValue
    spectrumValue[i] = constrain(spectrumValue[i], filterValue, 1023);


    // Remap the value to a number between 0 and 255
    spectrumValue[i] = map(spectrumValue[i], filterValue, 1023, 0, 255);

    // Remove serial stuff after debugging
    Serial.print(spectrumValue[i]);
    Serial.print(" ");
    digitalWrite(strobePin, HIGH);
  }

  Serial.println();

  
  int number = spectrumValue[1] + spectrumValue[2];
  number = constrain(number, 50, 245);
  number2 = number;
  if (40 > abs(number - number2) && abs(number-number2) != 0) {
    number = number2; 
  }
  number2 = number;
  analogWrite(ledPinPowerRed, number);
}

Let me know if you have any questions about why certain things are there. I currently have an if-statement at the bottom that I was working with to see if I can reduce the flickering.

Grumpy_Mike:
This is what I did with my MSGEQ7 chips :- Danse Macabre on Vimeo

Woah, that's a couple notches above my current knowledge haha. This project allowed me to get a rough idea of what you had to do to accomplish such a video, and I find that so fascinating! Thanks for sharing, I appreciate the endless possibilities that technology can do.

Also, what would you suggest to do with the code to prevent the lights from flickering so much

Subtract a fixed value from the results before you apply them to the lights. In that way you subtract the noise, make sure any negitave value is set to zero.

The LED lights seem to pick up audio played through my phone only and not my laptop.

Either the connection is bad or the laptop settings are such that no sound is output on the headphone socket. Check it with real headphones.