After reading the post on BPM this morning i decided to post a function for the MSGEQ7. The example that most people first try has lots of Delay statements in it, this is ok for the demo but you will probably not want them there when you integrate it into your existing project.
I don't know if this is the best way to do it but i think it's probably easy to understand for beginners like me.
Basically you just keep calling EQScan after 14 call's it will have filled spectrumValue[] with the data. Instead of using Delay you are doing the other stuff in your program instead to cause the delay
/*
EQ with no delay
evp
*/
byte spectrumValue[7];
void setup() {
pinMode(A3, INPUT); //analogPin
pinMode(A2, OUTPUT); //strobePin
pinMode(A1, OUTPUT); //resetPin
analogReference(DEFAULT);
digitalWrite(A1, LOW); // reset
digitalWrite(A2, HIGH);//
}
void loop() {
// what ever you want to do, i think it would be best to do somr thing or put in a delay
EQScan();
}
void EQScan(void){
static boolean ReadStrobe=0;
static byte Count=0;
if(Count>6){
Count=0;
digitalWrite(A1, HIGH); // reset
digitalWrite(A1, LOW);
}
if(ReadStrobe==0){ /// if ReadStrobe==0 then set the strobe and return else read analog input
digitalWrite(A2, LOW);
ReadStrobe=1;
}
else{
spectrumValue[Count] = analogRead(A3); ///
digitalWrite(A2, HIGH);
ReadStrobe=0;
}
Count+=1;
return;
}