Cambios

Dependencies:   mbed Adafruit_GFX SeeedShieldBot BluetoothSerial

Files at this revision

API Documentation at this revision

Comitter:
arturodeusto
Date:
Mon Dec 21 12:33:29 2020 +0000
Parent:
0:92bf762d49fa
Child:
2:8e21f1f358bc
Commit message:
casi funciona

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
resources/official_armmbed_example_badge.png Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sun Dec 20 22:27:31 2020 +0000
+++ b/main.cpp	Mon Dec 21 12:33:29 2020 +0000
@@ -67,11 +67,11 @@
         if (dato=='1') {            //Si el dato es un 1 comienza el proceso
 
             estado = movder;
+            //gOled.printf("Transportando\n");
+            bt.printf("Transportando\n");
 
 
         } else {      //Si el dato es cualquier otra cosa no empieza a hacer nada
-
-            pc.printf("Reposo\n");
         }
     }
 }
@@ -87,34 +87,37 @@
         wait_us(100);
         step=0;
         wait_us(900);
-        pc.printf("Estado: Moviendo derecha\n");
-        gOled.printf("Transportando\n");
     } else {
         enable=0;
         estado=calentar;
-        gOled.clearDisplay();
+        //gOled.clearDisplay();
+        //gOled.printf("Calentando\n");
+        bt.printf("Calentando\n");
+        
     }
 }
 
 void estadocalentar()
 {
+    rele=1;
     float tension=Vout.read()*3.3;
     //pc.printf("Valor voltios %.4f leido flat\n",tension);
 
     float resistencia= ((3.3*100000.0)/tension)-100000.0;
 
     float temp= 3950.0/(log(resistencia/100000.0)+(3950.0/298.0));
-    gOled.printf("Calentando a: %.4f\n",temp);
+    bt.printf("Calentando a: %.4f\n",temp);
+    //gOled.printf("Calentando a: %.4f\n",temp);
 
-    if (temp<35.0) {
+    if (temp<308.0) {
         //rele.write(1);
-        rele=1;
-        pc.printf("Estado: Rele activado\n");
 
     } else {
         rele=0;
         estado=movizq1;
         //gOled.clearDisplay();
+        //gOled.printf("Transportando\n");
+        bt.printf("Transportando\n");
     }
 }
 
@@ -122,6 +125,7 @@
 {
     unsigned int dist;
     usensor.start();
+    wait(0.01);
     dist=usensor.get_dist_cm();
 
     if(dist>20) {
@@ -131,12 +135,13 @@
         wait_us(100);
         step=0;
         wait_us(900);
-        pc.printf("Estado: Moviendo izquierda1\n");
-        gOled.printf("Transportando\n");
+
     } else {
         enable=0;
         estado=centro;
-        gOled.clearDisplay();
+        //gOled.clearDisplay();
+        //gOled.printf("Comprobar\n");
+        bt.printf("Centro\n");
     }
 }
 
@@ -151,12 +156,15 @@
         if (dato=='2') {            //Si el dato es un 1 comienza el proceso
 
             estado = movder;
-            gOled.printf("Pieza incorrecta\n");
+            //gOled.printf("Pieza incorrecta\n");
+            bt.printf("Pieza incorrecta\n");
+            
 
         } else if(dato=='3') {      //Si el dato es una b enciende el led
 
             estado = movizq2;
-            gOled.printf("Pieza correcta\n");
+            //gOled.printf("Pieza correcta\n");
+            bt.printf("Pieza correcta\n");
         }
     }
 }
@@ -165,28 +173,32 @@
 {
     if(final2==0) {
         enable=1; //activar el motor
-        dir=1; //direccion hacia la derecha
+        dir=0; //direccion hacia la derecha
         step=1; // avanzar
         wait_us(100);
         step=0;
         wait_us(900);
-        pc.printf("Estado: Moviendo izquierda2\n");
-        gOled.printf("Transportando\n");
     } else {
         enable=0;
         estado=soplado;
-        gOled.clearDisplay();
+        //gOled.clearDisplay();
+        //gOled.printf("Soplando\n");
+        bt.printf("Soplando\n");
     }
 }
 
 void estadosoplado()
 {
-
+    dirAMotor=0;
+    dirBMotor=1;
+    wait(5);
     dirAMotor=0;
-    pc.printf("Soplando pieza");
-    gOled.printf("Soplando");
-    wait(5);
+    dirBMotor=0;
     estado=inicio;
+    //gOled.clearDisplay();
+    //gOled.printf("Reposo\n");
+    bt.printf("Reposo\n");
+    
 
 }
 
@@ -196,8 +208,10 @@
 {
     pc.baud(115200);
     estado = inicio;
-    gOled.begin();
-    gOled.clearDisplay();
+    //gOled.begin();
+    //gOled.clearDisplay();
+    //gOled.printf("Reposo\n");
+    bt.printf("Reposo\n");
 
     repeticion.attach(&medir_corriente, 5.0); //Medir la intensidad cada tres segundos
 
Binary file resources/official_armmbed_example_badge.png has changed