Not sure if code is complete on a electret mic with volume meter to play music.

Hi
I’m building a project that registers noise amount and when the noise gets too loud the program will kick start a cd player blasting music. From instructables.com http://www.instructables.com/id/How-to-Deal-with-Noisy-Neighbors/
Received a copy of the code but not sure if it is the final working product and was wondering if anyone could help me out and point out if I am missing important information.
When I upload the code to the arduino mega there is no errors but some reason the mic doesn’t register and led bar graph doesn’t light up.
any help would be appreciated and I have basic knowledge of c++ but first solo project actually working on.
Also include pic flies of my circuit.
Made only one change to code and was added “;” after the i in the void setup.
Code is

[#// these constants won't change: 
const int sensorPin = A0; // the mic is connected to analog pin 0 
const int threshold = 320; // threshold value to decide when the detected sound is loud enough 
const int ledPin[] = { 2,3,4,5,6,7,8,9,10,11,12,13}; // led bars 
const int ledCount = sizeof(ledPin)/sizeof(int); // number of LEDs 
const int waitingPin = 1; 
const int playPin = 0; 
const int playDelay = 30; // delay for knight rider play pattern 
const long waitTime = 10000.0; // how long after trigger to wait before playing music 
const long cancelTime = 4000.0; // during wait, how long of a lull will cancel wait 
const long playTime = 30000.0; // how long to play payback music for // these variables will change: 
int sensorReading = 0; // variable to store the value read from the sensor pin 
int ledLevel = 0;
boolean waiting = 0;
boolean playing = 0; 
long waitStart; // when trigger initiated waiting 
long waitDuration; // how long we have been waiting 
long playStart; // when play was initiated 
long playDuration; // how long we've been playing 
long cancelStart; // when the last trigger was 
long cancelDuration;// how long of a lull we've had 
void setup() { 
  for(int i=0; i;  cancelTime) { waiting = 0; 
digitalWrite(waitingPin, LOW); 
} 
if (waitDuration > waitTime) { waiting = 0; 
digitalWrite(waitingPin, LOW); 
playing = 1; 
digitalWrite(playPin, LOW); 
delay(200); 
digitalWrite(playPin, HIGH); 
playStart = millis();
while (playing) { playDuration = millis() - playStart; 
if (playDuration > playTime) { digitalWrite(playPin, LOW);
delay(200); 
digitalWrite(playPin, HIGH);
playing = 0; 
} 
for (int i = 0; 
  i < ledCount; i++) { digitalWrite(ledPin[i], HIGH); 
delay(playDelay); 
digitalWrite(ledPin[i], LOW); 
delay(playDelay);
} 
for (int i = (ledCount - 1); 
  i >= 0; i--) { digitalWrite(ledPin[i], HIGH);
delay(playDelay);
digitalWrite(ledPin[i], LOW);
delay(playDelay); } } } } 
void loop () {
}/code]

const long waitTime = 10000.0; // how long after trigger to wait before playing music 
const long cancelTime = 4000.0; // during wait, how long of a lull will cancel wait 
const long playTime = 30000.0; // how long to play payback music for // these variables will change:

If that is any indication of the quality of the instructable, it's up to it's usual quality standard. Pure garbage, as most instructables seem to be.

  for(int i=0; i;  cancelTime) { waiting = 0; 
digitalWrite(waitingPin, LOW); 
}

The middle clause of a for loop is a while condition. While i is what?

Why would you need to set waiting to 0 more than once? Why would you need to set the pin low more than once?

After that, the piss-poor indenting caused me to quit reading.

Thank you for taking time to help out I understand that this code is bad so I decided to make my own. Any suggestions that you may have could help me out.

What I want the project to do is have mic hear noise and have led bar graph (record or sense) the noise,. When the noise level reaches the set threshold a signal is sent to pin connected to cd player to turn on and play. As playing, music pauses then program listens for more noise and if there is noise it continues again or no noise then music turns off.

Not asking to write me the code just some insight/tips on how I can write. I'm thinking for loop section to use for, while, if, else statements.

Not asking to write me the code just some insight/tips on how I can write. I’m thinking for loop section to use for, while, if, else statements.

The usual approach is to develop the application one step at a time. What is the hardest part about the project? Do that first. If it all looks hard, what is the first piece of information that you need? Get that first.

In your project, what is the first piece of information that you need? The reading from the microphone drives everything else. So, work on getting that first, and printing the reading to the Serial Monitor - analogRead() and Serial.print().

Once you know that you can get varying values as the noise level increases and decreases, you can develop the rest of the project. If you can’t, you need to work on the hardware aspects.

Note ther is very little correlation between how loud a sound sounds and the peak voltage of the waveform.