 #include <Average.h>
 
-#define Trig_pin 4
+#define Trig_pin 11
 
-volatile unsigned long echoBufferx[2];
-volatile unsigned long echoBuffery[2];
+volatile unsigned long echoBuffer[2];
 
 volatile unsigned int x = 0;
-volatile unsigned int y = 0;
 
 Average<float> ave(5);
 

  delayMicroseconds(10);
  digitalWrite(Trig_pin, LOW);

  delay(300);

  if ( echoBufferx[1] > echoBufferx[0]   ) {
    distancex = ( echoBufferx[1] - echoBufferx[0] ) / 29 / 2 ;
  } else {
    distancex = 1000 ;
  }

  if ( echoBuffery[1] > echoBuffery[0]  ) {
     distancey = ( echoBuffery[1] - echoBuffery[0] ) / 29 / 2 ;
  } else {
    distancey = 1000;
  }

  detachInterrupt(0);
  detachInterrupt(1);

  if ( distancex >= distancey ) {
    return distancey;
  } else {
    return distancex;
  }

}

void loop() {

  Serial.begin (38400);
  pinMode(Trig_pin, OUTPUT);
  pinMode(2, INPUT_PULLUP);
}

long check_distance() {

  x = 0 ;

  int distance = 0;

  for ( int i = 0 ; i < 2 ; i++ ) {
    echoBuffer[i] = 0;
  }

  attachInterrupt(0, echo_Interrupt_Handler, CHANGE);

  delay(200);

