Josimar Hernandez / Mbed 2 deprecated CUADRUPEDO

Dependencies:   mbed

Revision:
3:8bc95fb7c59c
Parent:
2:ee9eb5f76979
--- a/main.cpp	Tue Nov 20 01:56:56 2018 +0000
+++ b/main.cpp	Thu Nov 22 02:15:39 2018 +0000
@@ -1,3 +1,13 @@
+/*Sistemas Embebidos
+ Presentado a:
+  Ingeniero Ferney Beltran 
+ presentado por:
+ John Vanegas 
+ Josimar Hernandez
+ Sebastian Aldana
+ Sergio Fonseca
+*/
+
 #include "mbed.h"
 #include "main.h"
 
@@ -377,8 +387,9 @@
                 S3=1;
                 verde=Detectar();
                 
-                if ((rojo>2)&(rojo<25) & (azul>35)&(azul<54) & (verde>53)&(verde<73)){
-                    Transmi.printf("rojo. \n");
+                if ((rojo>300)&(rojo<460) & (azul>100)&(azul<160) & (verde>200)&(verde<310)){
+                    
+                    Transmi.printf("AZUL \n");
             Servo1.pulsewidth_us(1025);
             wait (0.5);
             Servo2.pulsewidth_us(1319);
@@ -412,8 +423,9 @@
                     }
                     
                     else{
-                        if ((rojo>130)&(rojo<152) & (azul>35)&(azul<56) & (verde>91)&(verde<114)){
-                                Transmi.printf("azul. \n");
+                        if ((rojo>70)&(rojo<80) & (azul>170)&(azul<220) & (verde>250)&(verde<300)){
+                            
+                            Transmi.printf("ROJO\n");
                                   Servo1.pulsewidth_us(1025);
             wait (0.5);
             Servo2.pulsewidth_us(1711);
@@ -448,8 +460,9 @@
                            
                             else{
                                 
-                                if ((rojo>10)&(rojo<24) & (azul>25)&(azul<36) & (verde>23)&(verde<34)){
-                                    Transmi.printf("verde. \n");
+                                if ((rojo>90)&(rojo<120) & (azul>121)&(azul<170) & (verde>100)&(verde<110)){
+                            
+                           Transmi.printf("VERDE\n");
                                 Servo1.pulsewidth_us(700);
                                 wait (1);
                                 Servo3.pulsewidth_us(700);
@@ -508,88 +521,78 @@
 
     while(funcion==4) {
 
-        medir_r = analog_1.read(); // Lee el valor de entrada analógica (valor de 0.0 a 1.0 = rango de conversión de ADC completo)
-
-        medir_v = medir_r * 3300; // Convierte valor en el rango 0V-3.3V.
+        medir_r = analog_1.read();
 
-        
-        // Display values
-     //   printf("medida = %f = %.0f mV\n", medir_r, medir_v);
+        medir_v = medir_r * 3300; 
 
-        
-// El LED está encendido si el valor está por debajo de 1 V
         if (medir_v < 1000) {             
               
             Servo1.pulsewidth_us(1025);
             Servo2.pulsewidth_us(1319);
-            wait (0.5);     
+            wait (0.3);     
             Servo1.pulsewidth_us(1412);
-            wait (0.5);
+            wait (0.3);
                  
             Servo7.pulsewidth_us(1025);
             Servo8.pulsewidth_us(1809);
-            wait (0.5);
+            wait (0.3);
             Servo7.pulsewidth_us(1417);
-            wait (0.5);
+            wait (0.3);
             
             Servo2.pulsewidth_us(1515);
             Servo8.pulsewidth_us(1515);
-            wait (0.5);
+            wait (0.3);
             Servo3.pulsewidth_us(1221);
             Servo4.pulsewidth_us(1613);
-            wait (0.5);
+            wait (0.3);
             Servo3.pulsewidth_us(1613);
-            wait (0.5);
+            wait (0.3);
             
             Servo5.pulsewidth_us(731);
             Servo6.pulsewidth_us(1025);
-            wait (0.5);
+            wait (0.3);
             Servo5.pulsewidth_us(1025);
-            wait (0.5);
+            wait (0.3);
             
             Servo4.pulsewidth_us(1417);
             Servo6.pulsewidth_us(1417);
-            wait (0.5);
-             
-             
-             
-             // LED ON
-           
+            wait (0.3);
+                 
         } else {
             if (medir_v > 2000){
-                 wait (0.5);
+            wait (0.3);
             Servo2.pulsewidth_us(1711);
-            wait (0.5);     
+            wait (0.3);     
             Servo1.pulsewidth_us(1412);
-            wait (0.5);     
+            wait (0.3);     
             Servo7.pulsewidth_us(1025);
-            wait (0.5);
+            wait (0.3);
             Servo8.pulsewidth_us(1319);
-            wait (0.5);
+            wait (0.3);
             Servo7.pulsewidth_us(1417);
-            wait (0.5);
+            wait (0.3);
             Servo2.pulsewidth_us(1515);
             Servo8.pulsewidth_us(1515);
-            wait (0.5);
+            wait (0.3);
             Servo3.pulsewidth_us(1221);
-            wait (0.5);
+            wait (0.3);
             Servo4.pulsewidth_us(1025);
-            wait (0.5);
+            wait (0.3);
             Servo3.pulsewidth_us(1613);
-            wait (0.5);
+            wait (0.3);
             Servo5.pulsewidth_us(731);
-            wait (0.5);
+            wait (0.3);
             Servo6.pulsewidth_us(1613);
-            wait (0.5);
+            wait (0.3);
             Servo5.pulsewidth_us(1025);
-            wait (0.5);
+            wait (0.3);
             Servo4.pulsewidth_us(1417);
             Servo6.pulsewidth_us(1417);
-            wait (0.5); 
+            wait (0.3); 
                 
         }
-    
-        wait (1.0);
+        else{    
+        wait (1.0);}
         }
         }
         }