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!