Arduino Sound Sensor

Hello, i build module like this http://tinkerlog.com/2007/10/22/diy-tengu-on-a-breadboard/
I achieve results: clap hands the robot is start to go, when next clap robot is stopping.
That work fine. But i have question how get work douple clap ?

int potPin = 2;    // select the input pin for sound sensor  
int ledPin = 13;   // select the pin for the LED  
int val = 0;  
int amp = 0;  
int go = 0;  
  
void setup() {  
  pinMode(ledPin, OUTPUT);  // declare the ledPin as an OUTPUT  
}  
  
void loop() {  
  val = analogRead(potPin);  
  amp = (val >= 512) ? val - 512 : 512 - val;  
 
  if (amp > 100) {    
  digitalWrite(ledPin, HIGH);  
  delay(20);  
        
  if  (go == 0)
{  
  motor.start
  go = 1;  
}
    
else 
{
 motor.stop
  go = 0;
}
  }  
  
else 
  {  
  digitalWrite(ledPin, LOW);  
  }  

}

The trick is to remember the timestamp of the last clap, and if the delta is less than some value - e.g. 500 millis() - consider it a double clap.

patched your code a bit to get you started …

int potPin = 2;    // select the input pin for sound sensor  
int ledPin = 13;   // select the pin for the LED  
int val = 0;  
int amp = 0;  
int go = 0;  

unsigned long lastClap = 0;
unsigned long nowClap = 0;
unsigned int claps = 0;
#define DOUBLECLAPTHRESHOLD 500

void setup() 
{  
  pinMode(ledPin, OUTPUT);  // declare the ledPin as an OUTPUT  
}  

void loop() 
{
  // READ THE SENSOR  
  val = analogRead(potPin);  
  amp = (val >= 512) ? val - 512 : 512 - val;  // amp = abs(val-512);

  // COUNT THE CLAPS
  if (amp > 100) // threshold
  {
    nowClap = millis();
    claps = 1;
    if (nowClap - lastClap < DOUBLECLAPTHRESHOLD) claps = 2;
    lastClap = nowClap;
  }
    
  Serial.println(claps, DEC);

  // ACT ON THE NR OF CLAPS
  switch(claps)
  {
  case 0:  // DO NOTHING
    digitalWrite(ledPin, LOW);
    break;
  case 1: // SINGLECLAP
    digitalWrite(ledPin, HIGH);
    // motor.start(); // to be defined
    break;
  case 2: // DOUBLECLAP
    digitalWrite(ledPin, HIGH);
    // motor.stop();  // to be defined
    break;
  default:  // UNDEFINED NR CLAPS
    break;
  }
}

Could you tell me how do i go about making my robot move (dance) to dethmetal using the same sensor? i have a 4wd rover and a mega 2560

i want to make a robot that would go forward on one clap backwards on two left on three and right on four pls advice on the arduino ide code pls help i a a beginner to this and i do not know how to program pls help

If we code it for you yo never will learn, first give it a serious try yourself

If it does not work we can help based upon YOUR code.