int buffer = 0; //Sound variables int potPin = 1; // select the input pin for sound sensor int ledPin = 13; // select the pin for the LED int soundVal = 0; void setup() { pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT Serial.begin(9600); // open the serial port at 9600 bps: } void loop() { //Sound soundVal = analogRead(potPin); //Serial.println("Listening............"); if( soundVal>1020 ){ Serial.println("VERY LOUD!"); digitalWrite(ledPin,HIGH); } else if (soundVal<450 || soundVal >750){ if (buffer == 0){ Serial.println(soundVal); buffer = 15; digitalWrite(ledPin,HIGH); }else{ buffer--; } } else{ digitalWrite(ledPin,LOW); } }