Here is the video of my final documentation. I am sorry it is a little longer over the maximum time.
https://www.dropbox.com/s/w5xj2nrwgz6kp19/Final%20Documentation%20Video%20.mov?dl=0
Here is the code I used:
int sensorPin = A1; // select the input pin for the electret mic
int ledPin = 5; // LED connected to digital pin 5
int ledPin2 = 6; // LED connected to digital pin 6
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 delayTime = 20;
void setup(){
Serial.begin(9600);
pinMode(7, OUTPUT);
pinMode(4, OUTPUT);
// pinMode(6, OUTPUT);
// for(int i = 4; i<8; i++) // all off
digitalWrite(4, HIGH);
digitalWrite(7, HIGH);
//digitalWrite(6, HIGH);
}
//
//void setEL(int ch) // set a certain EL on
//{
// for(int i = 4; i<8; i++) // all off
// digitalWrite(i, LOW);
// digitalWrite(ch+3, HIGH); // ch on
// for(int i = 4; i<8; i++) // all off
// digitalWrite(i, HIGH);
//}
//
//int count = 0;
//}
void loop(){
volume = analogRead(sensorPin);
// volume= abs(volume-450); // look at the base value when room is quiet and subtract by that amount – it may not be 760
if (volume < 1000) {
volume = 1000;
}
////
volume2 = map(volume, 1000, 1023, 95, 255); // if you need to subtract 760 (as suggested above), change the initial range to 0, 263 instead of 0, 1023
// below 80 shows more flicker
analogWrite(ledPin, volume2);
analogWrite(ledPin2, volume2);
Serial.println(volume);
// Serial.print(“t”); //prints a tab
// Serial.print(“t”); //prints a tab
// Serial.println(volume2);
// delay(delayTime);
}
//setEL(count%4 + 1);
// delay(200);
// if(count++ == 1000)
// {
// count = 0;
//}