This is the beginning of my code so far
int sensorPin = A0; // select the input pin for the electret mic
int ledPin = 9; // LED connected to digital pin 9
int volume = 0; // variable to store the volume level value coming from the sensor
int volume2 = 0; // variable to store the volume level value coming from the sensor – mapped to a range of 0-255
int volume3 = 0; // variable to store the volume level value coming from the sensor – mapped to a range of 0-255
int delayTime = 10;
int ledPin2 = 10;
void setup() {
Serial.begin(9600);
}
void loop() {
volume = analogRead(sensorPin);
// volume=abs(volume-1000); // look at the base value when room is quiet and subtract by that amount – it may not be 760
//if (volume < 760) {
if (volume < 740) { // more sensative the higher the number ie, 800 + 390
volume=abs(volume-410);
volume2 = map(volume, 0, 330, 0, 255); // if you need to subtract 760 (as suggested above), change the initial range to 0, 263 instead of 0, 1023
// 390 more sensative than 350
//760 – 410 =350
volume2 = abs(volume2 – 254);
volume3 = map(volume, 0, 350, 0, 255); // if you need to subtract 760 (as suggested above), change the initial range to 0, 263 instead of 0, 1023
volume3 = abs(volume2 – 254);
if (volume2 > 22) {
analogWrite(ledPin, volume2);
analogWrite(ledPin2, volume3);
}
else {
analogWrite(ledPin, 0);
analogWrite(ledPin2, 0);
}
// analogWrite(ledPin, volume);
// Serial.print(volume);
// Serial.print(“t”); //prints a tab
// Serial.print(“t”); //prints a tab
// Serial.println(volume2);
}
// Serial.print(volume);
// Serial.print(“t”); //prints a tab
// Serial.print(“t”); //prints a tab
// Serial.println(volume2);
delay(delayTime);
// volume = analogRead(sensorPin);
// // volume=abs(analogValue-760); // look at the base value when room is quiet and subtract by that amount – it may not be 760
// volume2 = map(volume, 0, 25, 0, 255); // if you need to subtract 760 (as suggested above), change the initial range to 0, 263 instead of 0, 1023
// analogWrite(ledPin2, volume2);
// Serial.print(volume);
// Serial.print(“t”); //prints a tab
// Serial.print(“t”); //prints a tab
// Serial.println(volume2);
// delay(delayTime);
}
I just need to add some more LED inputs and change the sensitivity.
I got my LED’s from sparkfun.com