Simple clap code?

Ive been trying to come up with a way to make a clap on switch with arduino. No success.

So ive got a simple LED connected to the PIN 10, and an sound sensor module on PIN 7. Can i get some guidelines on the way to write the code, so when i clap, LED turns ON and stays ON until next clap. Since its the 3mm green LED, im using the analogWrite() with a value of 48 since thats the duty cycle for that led so i dont burn it.

So help would be appreciated, like how would i read the state of the LED (is it ON or OFF) etc.....

ViTALiTY: Ive been trying to come up with a way to make a clap on switch with arduino. No success.

So ive got a simple LED connected to the PIN 10, and an sound sensor module on PIN 7. Can i get some guidelines on the way to write the code, so when i clap, LED turns ON and stays ON until next clap. Since its the 3mm green LED, im using the analogWrite() with a value of 48 since thats the duty cycle for that led so i dont burn it.

So help would be appreciated, like how would i read the state of the LED (is it ON or OFF) etc.....

The last two bits don't make any sense. I don't know what you mean by a duty cycle for an LED. You can supply constant power to an LED, you just need a resistor to limit the current.

And the last sentence, how to read the state of the LED. Who set the state of the LED? You did. In the code. You don't know what state you set it to? You shouldn't need to read it. You can, just read the port with a digitalRead just like you would if it was an input. It will tell you how you have it set. But you should really never need to do that. That would make for some confusing code.

As far as the clapping thing goes, that I don't know. How are you detecting the clap? Is this a microphone or something?

If you want code that keeps the LED on you could do something like

pseudocode because I don't know how you read this clap sensor.

void loop(){

static bool clapOn = false;

if (readTheClapSensor()) {
     clapOn = !clapOn;
}
if (clapOn){
     digitalWrite(10, HIGH);
} else {
     digitalWrite(10, LOW);
}
}

where readTheClapSensor() is a function or expression that returns true when there is a clap.

In this way the light will stay on until you clap again and the boolean gets toggled again.