IMTcchallenge para prepos

Dependencies:   Servo mbed

Revision:
1:d47f3431441b
Parent:
0:21188b66200a
--- a/main.cpp	Thu Oct 15 17:25:56 2015 +0000
+++ b/main.cpp	Fri Oct 16 04:51:42 2015 +0000
@@ -22,8 +22,9 @@
  void ServosMovingTogether(float, float, float, float, float);
  
 //*********Macros Defines*********************
-#define MidStepDelay 1  //modificar este valor para el tiempo entre el movimiento de un motor y otro
-#define GenralLoopDelay 1 //Modificar este valor para el tiempo entre una secuencia de movimiento de 5 motores y la secuencia siguiente
+#define MIDSTEPDELAY 1     //modificar este valor para el tiempo entre el movimiento de un motor y otro
+#define GENERALLOOPDELAY 1 //Modificar este valor para el tiempo entre una secuencia de movimiento de 5 motores y la secuencia siguiente
+#define LOOPSNUMBER 1      //Modificar este valor segun a la cantidad de veces que quiere repetir la rutina
 
 //Comando para iniciar un comunicacion entre la FRDM-KL-Z y la computador
 
@@ -33,15 +34,51 @@
 //--------------------------------------------------------------------
 int main(){
     
+    char StartBit= '\0';
+    int temp= LOOPSNUMBER; 
+    
     pc.baud(9600); //Velocidad de la comunicacion entre la tarjeta y la computadora 
     
     printf("\nBienvenido\n\n Iniciando la rutina del IMTarm");
     while(1){  //Loop infinito
     
+    printf("\nPresione cualquer tecla para empezar\n");
+    StartBit=pc.getc();
+    
+    if(StartBit!=0)
+    {
+        StartBit='\0';
+        do
+        {
         ServosMovingTogether(0.5,0.5,0.5,0.5,0.5);
-        wait(GenralLoopDelay);
+        //---------------------|   |   |   |   |   Garra
+        //---------------------|   |   |   |       Muneca
+        //---------------------|   |   |           Codo
+        //---------------------|   |               Hombro
+        //---------------------|                   Eje
+        
+        wait(GENERALLOOPDELAY);
+        //*********************************************************
+        //******Modificar a partir de este punto*******************
+        //*********************************************************
+        
+        ServosMovingTogether(0.125,0.6,0.05,0.975,0.975);
+        wait(GENERALLOOPDELAY);
         
-
+        
+        ServosMovingTogether(0.125,0.55,0.0,0.975,0.775);
+        wait(GENERALLOOPDELAY);
+        
+        
+        ServosMovingTogether(0.125,0.35,0.40,0.975,0.775);
+        wait(GENERALLOOPDELAY);
+        
+        
+        ServosMovingTogether(0.825,0.35,0.40,0.975,0.975);
+        wait(GENERALLOOPDELAY);
+        //***********Dejar de Modificar******************
+        }while(--temp);
+    }
     }//Fin del Loop infinito
     
  //+++++++++++++++++++++++++++++++++++++++++++++++
@@ -57,18 +94,17 @@
  void ServosMovingTogether(float EjePos, float HombroPos, float CodoPos, float MunecaPos, float GarraPos)
 {
     Eje=EjePos;
-    wait (MidStepDelay);
+    wait (MIDSTEPDELAY);
     
-    Hombro=HombroPos;
-    wait (MidStepDelay);
+    Muneca=MunecaPos;
+    wait (MIDSTEPDELAY);
     
     Codo=CodoPos;
-    wait (MidStepDelay);
-        
-    Muneca=MunecaPos;
-    wait (MidStepDelay);
-        
+    wait (MIDSTEPDELAY);
+    
+    Hombro=HombroPos;
+    wait (MIDSTEPDELAY);
     
     Garra=GarraPos;
-    wait (MidStepDelay);
+    wait (MIDSTEPDELAY);
 }
\ No newline at end of file