I started fresh and reconnected the chip. And it seems that the chip is not outputting any high frequency noise! It must've been a bad wiring issue.
But, I'm still having the same problem: I'm still getting a small output from my LEDs. Trying to short the input or short the Arduino analog pin 0 to ground doesn't work anymore, I'm beginning to think this could be a code issue.
Quote
It means the opposite. The noise is coming from the MSGEQ7.
Did you connect all the recommended capacitors as shown by the MSGEQ7 data sheet? Do you have another MSGEQ7 you can try?
I'm actually using a couple different values. I'm using a 270k resistor to 5v (pin instead of a 200k and a 20k resistor to input (pin 5) instead of a 22k. I'm also using a 100 pico farad cap in pin 1 to ground instead of a 33 pico farad (trying to go to the electronics store tomorrow and look for one).
Try the same shorting technique on the Arduino analog input pin.
Just tried this and the LEDs stopped flickering, meaning the output through the serial monitor continuously outputted "0." Does this mean the noise is coming from the Arduino itself?
Your "problem" of having a signal diferent from 0 when no playing music is problem of the sound card and not from your circuit, its called dc offset and every sound card, in fact every device that plays audio have it, so dont worry about it.
Even with no signal present (thus no sound/music) the LEDs are still flickering.
Here is a picture of my serial monitor when playing no music. I see that it is outputting values. Can I filter these values out using code?
Did you not read the part about shorting the input to the MSEQ7 or else you test is not valid? If you don't understand something don't just skip over it or we will assume you aren't serious and we will go and talk to other people who are more interested/interesting.
Sorry about that. I tried shorting the input to ground and I am still getting the LED flickering.
Quote
When your computer is connected to speakers can you hear high-frequency noise?
Yes, I do hear a high-frequency tone when I connect it to speakers. This noise is what I assume is the chip.
As for the map() function, I will look into it, although the main problem I am trying to address is getting rid of the chip noise.
What exactly does that mean? For it to be valid you would have to connect the input of the MSEQ7 to ground. Else, you are just measuring ambient noise and what you are seeing is normal.
I am using my computer as an input to a 3.5mm jack, connected to the MSGEQ7. While I am not sending a signal (playing music) into the chip, the LEDs remain slightly lit.
Quote
What value of current limiting resistor are you using on your LEDs?
Without a schematic (or block diagram) of how you hooked up your chip and without the code, it really isn't possible to determine which is causing problems.
I connected the chip using the schematic in my first post:
For an input I am using a 3.5mm jack connected to my computer.
Also, for my LEDs I am using a 220 ohm resistor. Do you think this is too low of a resistance?
I have also provided my code below:
Code:
int analogPin = 0; // read from multiplexer using analog input 0 int strobePin = 2; // strobe is attached to digital pin 2 int resetPin = 3; // reset is attached to digital pin 3 int spectrumValue[7]; // to hold a2d values int otherPin = 5; int otherPin2 = 6; int redPin = 9; int greenPin = 10; int bluePin = 11;
for (int i = 0; i < 7; i++) { digitalWrite(strobePin, LOW); delayMicroseconds(35); // to allow the output to settle spectrumValue[i] = analogRead(analogPin);
//comment out/remove the serial stuff to go faster // - its just here for show if (spectrumValue[i] < 10) { Serial.print(" "); Serial.print(spectrumValue[i]); } else if (spectrumValue[i] < 100 ) { Serial.print(" "); Serial.print(spectrumValue[i]); } else { Serial.print(" "); Serial.print(spectrumValue[i]); }
digitalWrite(strobePin, HIGH);
int otherout = spectrumValue[2]/4; int otherout2 = spectrumValue[3]/4; int redout = spectrumValue[4]/4; int greenout = spectrumValue[5]/4; int blueout = spectrumValue[6]/4; analogWrite(otherPin, otherout); analogWrite(otherPin2, otherout2); analogWrite(redPin, redout); // will set the LED output to the value of the zeroth index of your array. analogWrite(greenPin, greenout); analogWrite(bluePin, blueout); } Serial.println(); }
I seem to be getting a bit of noise with the chip. I'm using 5 LEDs with the Arduino, and even with no signal from my computer (like music) the LEDs are very dim because the chip is outputting some noise. Can anyone help me with this? Or can this be a programming issue?
and it seems very interesting. My question seems a little simple...but I don't have much programming knowledge.
I see that the code provided at the website prints the analog values between 0-1023 within an array. How would I write a code to read these values to control the brightness of an LED?
Here's the code provided at the website:
Code:
int analogPin = 0; // read from multiplexer using analog input 0 int strobePin = 2; // strobe is attached to digital pin 2 int resetPin = 3; // reset is attached to digital pin 3 int spectrumValue[7]; // to hold a2d values
for (int i = 0; i < 7; i++) { digitalWrite(strobePin, LOW); delayMicroseconds(30); // to allow the output to settle spectrumValue[i] = analogRead(analogPin);
// comment out/remove the serial stuff to go faster // - its just here for show if (spectrumValue[i] < 10) { Serial.print(" "); Serial.print(spectrumValue[i]); } else if (spectrumValue[i] < 100 ) { Serial.print(" "); Serial.print(spectrumValue[i]); } else { Serial.print(" "); Serial.print(spectrumValue[i]); }
Ok, I'll try to connect the microphone to another pre-amp circuit tonight.
Quote
So what way have you got it wired up? The code assumes current sinking but this correct way you just posted is current sourcing so the code is backwards for that.
I wired the RGB LED just as I wrote in my second post. The link I provided had the second pin going to power (current sinking?) and I connected it into ground (which I believe is correct).
I'm trying to find where I should modify the code, but my programming experience isn't as great as it should be. :-/ How should I fix the code for "current sourcing"?
That is what I would expect, you microphone only provides a tiny amount of voltage it will need amplifying.
I used the breakout board on the link provided which claims to already amplify the microphone. Should I amplify the circuit even more? Thus, using another op-amp?
Quote
The wiring in that link is total rubbish. You don't wire up an RGB LED anything like that. You appere to be sinking current through the arduino when it is on and through the resistor when it is off. I would expect the LED to be on all the time and get brighter when the arduino's output is low. I also would expect that the arduino and the LED will be damaged with this circuit as there is no effective current limiting resistor. The resistors that are in are in the wrong place to limit current.
I've connected all the wires properly and used the code provided, but I seem to get weird results.
Instead of the RGB LED changing colors acoording to the analog input, I'm finding that the LED is constantly blinking in all 3 colors. The other colors are not turning off when one color is supposed to turn on at a time. Ex. Red is constantly blinking while blue and green are constantly blinking at the same time. Red is supposed to blink by itself acoording to the input of the elecret microphone.
Here's the code provided:
Code:
/* //////////////////////////////////////////////////////////////////////////////// Bola musical luminosa
Es una bola que reacciona a la presion sonora iluminandose. Según el nivel se ilumina secuencialmente en azul, verde y rojo.
El circuito: * LED RGB de 4 patillas. Ánodo conectado a 5v, cátodos conectados a pines 9,10 y 11 y luego a tierra a través de resistencias de 220 Ohm. * Microfono preamplificado en pin analógico 0. (yo use el Breakout Board for Electret Microphone sku: BOB-08669 de sparkfun ). Tambien se puede utilizar cualquier elemento que nos proporcione un voltaje variable hasta 5V.
Vídeo: http://www.youtube.com/watch?v=_QrF_CfAFEY Mira tambien: http://www.youtube.com/watch?v=hckZEcqkg40
creado el 22 de junio de 2010 Por Alejandro Taracido Cano (TCRobotics) Canal de youtube: http://www.youtube.com/user/TCRobotics /////////////////////////////////////////////////////////////////////////////// Musical ball light
It is a ball that reacts to the sound pressure with light. According to the sound level it sequentially lights in blue, green and red.
The circuit: * 4-pin RGB LED. 5v connected to anode, cathodes connected to pin 9,10 and 11 and then to ground through 220 Ohm resistor. * Analog microphone preamplifiers in pin 0. (I use the Breakout Board for Electret Microphone sku: BOB-08 669 from SparkFun). You can also use anything that will give us a variable voltage between 5 and 0 volts.
Video: http://www.youtube.com/watch?v=_QrF_CfAFEY See also: http://www.youtube.com/watch?v=hckZEcqkg40
created 22 Jun 2010 By Alejandro Taracido Cano (TCRobotics) Youtube channel: http://www.youtube.com/user/TCRobotics //////////////////////////////////////////////////////////////////////////////// */ int MicPin = 0; // pin that the mic is attached to
int redPin = 9; // pins that the cathodes of LED are attached to int greenPin = 10; int bluePin = 11;
int MicValue = 0; // the Microphone value
void setup() { //Serial.begin(9600); //for test the input value initialize serial pinMode(redPin, OUTPUT); pinMode(greenPin, OUTPUT); pinMode(bluePin, OUTPUT);
analogWrite(redPin, 255); //turn off all LEDs analogWrite(greenPin, 255); analogWrite(bluePin, 255); }
void loop() {
MicValue = analogRead(MicPin); //read the value of the microphone
//Serial.println(MicValue); //for test the input value
if (MicValue > 530) { //adjust this value to the desired sensitivity analogWrite(bluePin,0); //lights up blue delay(15); //small delay for quick response at low noise levels }
if (MicValue > 540) { //adjust this value to the desired sensitivity analogWrite(bluePin,255); //lights up green and turn off blue analogWrite(greenPin, 0); delay(60); //mid delay for response at mid noise levels }
if (MicValue > 550) { //adjust this value to the desired sensitivity analogWrite(greenPin,255); //lights up red and turn off green analogWrite(redPin, 0); delay(140); //high delay for response at high noise levels }
analogWrite(greenPin, 255); //Turn off all LEDs analogWrite(redPin, 255); analogWrite(bluePin,255);
}
Also, the electret microphone seems to be outputting values around 500. When I talk into the microphone it doesn't seem to change much unless I actually tap the microphone (which then prints values of 0 and around 1000). Could this be the problem? I've connected AUD to analog input 0, GND to ground, and VCC to 5V.