I know this topic has been posted dozens of times, but I couldn't find exactly what I needed. I am not a very good coder at all. I can understand what is going on by reading code, not so good at implementing it myself. I would love any help or suggestions anyone can provide. I am using this code currently for my project:
int analogPin=0;
int strobePin=2;
int resetPin=3;
int ledred=9;
int ledblue=10;
int ledgreen=11;
int spectrumValue[7];
int filter=220;void setup(){
Serial.begin(9600);
pinMode(analogPin, INPUT);
pinMode(strobePin, OUTPUT);
pinMode(resetPin, OUTPUT);
pinMode(ledred, OUTPUT);
pinMode(ledblue, OUTPUT);
pinMode(ledgreen, OUTPUT);
digitalWrite(resetPin, LOW);
digitalWrite(strobePin, HIGH);
}void loop(){
digitalWrite(resetPin, HIGH);
digitalWrite(resetPin, LOW);
for (int i=0;i<7;i++){
digitalWrite(strobePin, LOW);
delay(30);
spectrumValue*=analogRead(analogPin);*
spectrumValue_=constrain(spectrumValue*, filter, 1023);
spectrumValue=map(spectrumValue, filter,1023,0,255);
Serial.print(spectrumValue);
Serial.print(" ");
digitalWrite(strobePin, HIGH);
}
Serial.println();
analogWrite(ledred,spectrumValue[0]);
analogWrite(ledred,spectrumValue[1]);
analogWrite(ledblue,spectrumValue[3]);
analogWrite(ledblue,spectrumValue[4]);
analogWrite(ledgreen,spectrumValue[5]);
analogWrite(ledgreen,spectrumValue[6]);
}[/quote]*
The issue that I run into is that I have to raise the filter the beginning because I kept picking up background noise, causing the lights to flicker with no sound playing. Is there anyway to filter out the noise that doesn't compromise the sensitivity of my lights?
Also, is there anyway to be able to calibrate the lights to the volume of the input? I use this with my records and Xbox, but the Xbox puts out a much louder signal. Therefore, I have to throw a headphone amp in between to regulate the output level._