Hello, everyone. I know there are dozens of posts about the MSGEQ7 chip (and believe me, I’ve read them), but I’ve run into an issue that I still can’t solve.
Purpose: to use the MSGEQ7 to analyze the spectrum of incoming music and output DC voltages proportional to the signal’s spectrum. This will be used to control a strip of programmable LEDs.
Datasheet: here
Circuit: here. The circuit design is straight from page 4 of the datasheet. Music comes in from my phone/laptop through an aux cord into the jack. Left and Right channels are connected via two 22KΩ resistors in series with a 0.01uF capacitor (I’ve also tried using a 0.1uF cap). A 33pF cap combined with two 100KΩ series resistors (making 200KΩ) make the clock. Strobe and Reset are connected to digital pins on the Arduino Mega. The DC output is connected to pin A0 on the Arduino.
I only use ceramic capacitors.
Code:
This is just a test script to make sure the chip works. This isn’t the code with the LED components. I’ve tried various test scripts found online by people who supposedly got it to work. I have two separate MSGEQ7 chips, and neither are working properly, so I doubt the issue is chip damage.
#define analogPin 0 //A0
#define strobePin 2 //strobe is attached to digital pin 2
#define resetPin 3 //reset is attached to digital pin 3
int spectrumValue[7]; // to hold a2d values
void setup()
{
Serial.begin(9600);
pinMode(strobePin, OUTPUT);
pinMode(resetPin, OUTPUT);
analogReference(DEFAULT);
digitalWrite(resetPin, LOW);
digitalWrite(strobePin, HIGH);
}
void loop()
{
digitalWrite(resetPin, HIGH);
digitalWrite(resetPin, LOW);
for (int i = 0; i < 7; i++)
{
digitalWrite(strobePin, LOW);
delayMicroseconds(40); // to allow the output to settle
spectrumValue[i] = analogRead(analogPin);
Serial.print(" ");
Serial.print(spectrumValue[i]);
delayMicroseconds(40);
digitalWrite(strobePin, HIGH);
}
Serial.println();
}
Problem: The values I get in the serial monitor are all in the 100s. The output should range from 0-1023, scaling most likely linearly with the strength of the signal; i.e. if I play a 63Hz sine wave, the output of the 63Hz bandpass should be in the 900-1023 range. But whether I play music or specific tones (e.g. 400Hz, 2.5KHz), the output doesn’t change at all. The output of every band remains in the 100-199 range.
Output: here. The output is now staying in the sub 100 range.
What have I done wrong?