int soundSensor = A2; // Define the sensor pin
int LED = D6; // Define the LED pin
int state; // Define state
int value; // Define value

void setup() 
{
  pinMode (soundSensor, INPUT); 
  //Set the sensor as an INPUT
  pinMode (LED, OUTPUT);
  //Set the LED as an OUTPUT
}

void loop() 
{
  value = digitalRead (soundSensor);
  // Define the state equal to the LED reading
  if (value == HIGH)
  // Establish the condition to light up
  {
    state = digitalRead(LED);
    digitalWrite(LED, !state);
    /* 
    If the state of the LED changes, it will
    turn off or on again
    */
    delay(500); // Ignition duration
  }
}

    

A R D U I N O