Something like this, but what do I put in the dalay (xxxxxx)?
const int ledPin = 3;
int sound = A0;
int threshold = 400;
int sensorValue = 0;
int ledState = LOW;
long previousMillis = 0;
long interval = 1000;
void setup()
{
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
}
void loop()
{
int sensorValue = analogRead(sound);
Serial.print("sensorValue ");
Serial.println(sensorValue);
if(sensorValue > threshold)
{
digitalWrite(ledPin, HIGH);
delay(100);
}
{
digitalWrite(ledPin, LOW);
delay(10);
}
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > interval) {
previousMillis = currentMillis;
}
if (ledState == LOW)
ledState = HIGH;
else
ledState = LOW;
digitalWrite(ledPin, ledState);
}