Sound sensor signals with time bracket I've tried many codes for this to work but anything isn't helping at all, so my code should work like this: If a sound sensor (3 pins, A2) sends 5 signals into the Arduino within 10 seconds (the time gap of every signal varies, but doesn't matter as long as it sends 5 signals), the LED (13) will light up. This is my recent code if it could help

int led=13;
int sensor=A2;

void setup()
{ 
   pinMode(led, OUTPUT);
    pinMode(sensor, INPUT);
    Serial.begin(9600);
}

void loop()
{
    unsigned long StartMillis = millis();
    unsigned long CurrentMillis = millis();
    int signal_count=digitalRead(sensor);
    int signal_limit=5;
    Serial.println(signal_count);

    while ((CurrentMillis - StartMillis)==5000)
    if (digitalRead(sensor)=0)
    {     signal_count ++;
        Serial.println(signal_count);
    }
    if (signal_count&gt;signal_limit) {
        digitalWrite(led, HIGH);
    }
    else {
    digitalWrite(led,LOW);
    }
}
Your handling of millis() is wrong. With these two lines:

unsigned long StartMillis = millis();
unsigned long CurrentMillis = millis();


StartMillis will always have the same value as CurrentMillis. (Ok, I guess its possible for millis() to return a value that's increased by 1 the second time it's called, but that is extremely unlikely. The 2 lines takes much less than a millisecond to execute.)

Your 

while ((CurrentMillis - StartMillis)==5000) 


will never evaluate to true, so the code in the while block will never execute.

This if statement is also wrong:

if (digitalRead(sensor)=0)


You want == (comparison) not = assignment. I'm surprised the compiler even allowed that to compile, since you are trying to set the function digitalRead(sensor) to 0, which doesn't make sense.

Change that code to read:

if (digitalRead(sensor)==0)


(Assuming you want the body of the if statement to execute when your sensor value is 0.)