 void swing(int steps, int T=1000);
 void upDown(int steps, int T=1000);
 void flapping(int steps, int T=1000);
+void dance();
+void primera_parte();
+void segunda_parte();
 
 void setup()
 {
-  Serial.begin(19200);
-  
-  servo[0].attach(PIN_RR);
-  servo[1].attach(PIN_RL);
-  servo[2].attach(PIN_YR);
-  servo[3].attach(PIN_YL);
-  
-  //EEPROM.write(0,TRIM_RR);
-  //EEPROM.write(1,TRIM_RL);
-  //EEPROM.write(2,TRIM_YR);
-  //EEPROM.write(3,TRIM_YL);
-  
-  int trim;
-  
-  if(EEPROM_TRIM){
-    for(int x=0;x<4;x++){
-      trim=EEPROM.read(x);
-      if(trim>128)trim=trim-256;
-      Serial.print("TRIM ");
-      Serial.print(x);
-      Serial.print(" en ");
-      Serial.println(trim);
-      servo[x].SetTrim(trim);
-    }
-  }
-  else{
-    servo[0].SetTrim(TRIM_RR);
-    servo[1].SetTrim(TRIM_RL);
-    servo[2].SetTrim(TRIM_YR);
-    servo[3].SetTrim(TRIM_YL);
-  }
-  
-  for(int i=0;i<4;i++) servo[i].SetPosition(90);
+	Serial.begin(19200);
+	
+	servo[0].attach(PIN_RR);
+	servo[1].attach(PIN_RL);
+	servo[2].attach(PIN_YR);
+	servo[3].attach(PIN_YL);
+	
+	//EEPROM.write(0,TRIM_RR);
+	//EEPROM.write(1,TRIM_RL);
+	//EEPROM.write(2,TRIM_YR);
+	//EEPROM.write(3,TRIM_YL);
+	
+	int trim;
+	
+	if(EEPROM_TRIM){
+		for(int x=0;x<4;x++){
+			trim=EEPROM.read(x);
+			if(trim>128)trim=trim-256;
+			Serial.print("TRIM ");
+			Serial.print(x);
+			Serial.print(" en ");
+			Serial.println(trim);
+			servo[x].SetTrim(trim);
+		}
+	}
+	else{
+		servo[0].SetTrim(TRIM_RR);
+		servo[1].SetTrim(TRIM_RL);
+		servo[2].SetTrim(TRIM_YR);
+		servo[3].SetTrim(TRIM_YL);
+	}
+	
+	for(int i=0;i<4;i++) servo[i].SetPosition(90);
 }
 
 // TEMPO: 121 BPM

//--           Juan Gonzalez (obijuan): juan.gonzalez@bq.com
//-----------------------------------------------------------------
#include <Servo.h>
#include <Oscillator.h>
#include <EEPROM.h>

#define N_SERVOS 4
//-- First step: Configure the pins where the servos are attached
/*
         --------------- 
        |     O   O     |
        |---------------|
YR 3==> |               | <== YL 2
         --------------- 
            ||     ||
            ||     ||
RR 5==>   -----   ------  <== RL 4
         |-----   ------|
*/
#define EEPROM_TRIM false 
// Activate to take callibration data from internal memory
#define TRIM_RR 7
#define TRIM_RL 4
#define TRIM_YR  4
#define TRIM_YL -7
//OTTO.setTrims(-7,-4,-4,7);

#define PIN_RR 5
#define PIN_RL 4
#define PIN_YR 3
#define PIN_YL 2

#define INTERVALTIME 10.0 



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);
}


