 int oldPosition[]={90,90,90,90};
 
 void moveNServos(int time, int  newPosition[]){
-  for(int i=0;i<N_SERVOS;i++)	increment[i] = ((newPosition[i])-oldPosition[i])/(time/INTERVALTIME);
-  
-  final_time =  millis() + time; 
-  
-  iteration = 1; 
-  while(millis() < final_time){ //Javi del futuro cambia esto  
-      interval_time = millis()+INTERVALTIME;  
-      
-      oneTime=0;      
-      while(millis()<interval_time){	  
-          if(oneTime<1){ 
-              for(int i=0;i<N_SERVOS;i++){
-                  servo[i].SetPosition(oldPosition[i] + (iteration * increment[i]));
-              }			
-              iteration++;
-              oneTime++;
-          }
-      }     
-  }   
-
-  for(int i=0;i<N_SERVOS;i++){	
-    oldPosition[i] = newPosition[i];
-  }   
+	for(int i=0;i<N_SERVOS;i++)	increment[i] = ((newPosition[i])-oldPosition[i])/(time/INTERVALTIME);
+	
+	final_time =  millis() + time; 
+	
+	iteration = 1; 
+	while(millis() < final_time){ //Javi del futuro cambia esto  //Javi se olvido de cambiarlo lol
+			interval_time = millis()+INTERVALTIME;  
+			
+			oneTime=0;      
+			while(millis()<interval_time){	  
+					if(oneTime<1){ 
+							for(int i=0;i<N_SERVOS;i++){
+									servo[i].SetPosition(oldPosition[i] + (iteration * increment[i]));
+							}			
+							iteration++;
+							oneTime++;
+					}
+			}     
+	}   
+
+	for(int i=0;i<N_SERVOS;i++){	
+		oldPosition[i] = newPosition[i];
+	}   
 }
 
 

////////////////////////////////////////////////////////////////////////////////////////

void oscillate(int A[N_SERVOS], int O[N_SERVOS], int T, double phase_diff[N_SERVOS]){
  for (int i=0; i<4; i++) {
    servo[i].SetO(O[i]);
    servo[i].SetA(A[i]);
    servo[i].SetT(T);
    servo[i].SetPh(phase_diff[i]);
  }
  double ref=millis();
   for (double x=ref; x<T+ref; x=millis()){
     for (int i=0; i<4; i++){
        servo[i].refresh();
     }
  }
}

unsigned long final_time;


void loop()
{

	dance();
	//Reiniciar la posicion de los servos
	for(int i=0;i<4;i++) servo[i].SetPosition(90);

}

void dance(){
	primera_parte();
	segunda_parte();
	moonWalkLeft(4,t*2);
	moonWalkRight(4,t*2);
	moonWalkLeft(4,t*2);
	moonWalkRight(4,t*2);
	primera_parte(); 
	crusaito(1,t*8);
	crusaito(1,t*7);

	for (int i=0; i<16; i++){
		flapping(1,t/4);
		delay(3*t/4);
	}
 
	moonWalkRight(4,t*2);
	moonWalkLeft(4,t*2);
	moonWalkRight(4,t*2);
	moonWalkLeft(4,t*2);

	drunk(t*4);
	drunk(t*4);
	drunk(t*4);
	drunk(t*4);
	kickLeft(t);
	kickRight(t);
	drunk(t*8);
	drunk(t*4);
	drunk(t/2);
	delay(t*4); 

	drunk(t/2);

	delay(t*4); 
	walk(2,t*2);
	backyard(2,t*2);
	goingUp(t*2);
	goingUp(t*1);
	noGravity(t*2);
	crusaito(1,t*2);
	crusaito(1,t*8);
	crusaito(1,t*2);
	crusaito(1,t*8);
	crusaito(1,t*2);
	crusaito(1,t*3);

	delay(t);
	primera_parte();
		for (int i=0; i<32; i++){
		flapping(1,t/2);
		delay(t/2);
	}
	
	for(int i=0;i<4;i++) servo[i].SetPosition(90);
}


