Hi,
I’m looking into making a sort of visual EQ for my next Arduino project. I’ve come across the MSGEQ7 (the part is avaliable on sparkfun)
I’ve been reading this website:
http://skoba.no-ip.org/msgeq7/
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:
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
void setup()
{
Serial.begin(9600);
pinMode(analogPin, INPUT);
pinMode(strobePin, OUTPUT);
pinMode(resetPin, OUTPUT);
analogReference(DEFAULT);
digitalWrite(resetPin, LOW);
digitalWrite(strobePin, HIGH);
Serial.println("MSGEQ7 test by J Skoba");
}
void loop()
{
digitalWrite(resetPin, HIGH);
digitalWrite(resetPin, LOW);
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]);
}
digitalWrite(strobePin, HIGH);
}
Serial.println();
}