p5e6

Dependencies:   mbed

Revision:
31:6c36768769ea
Parent:
30:f7518060fc89
Child:
32:b229ddfa279f
--- a/main.cpp	Tue Oct 22 19:20:06 2019 +0000
+++ b/main.cpp	Thu Oct 31 04:24:05 2019 +0000
@@ -1,23 +1,39 @@
 #include "mbed.h"
 Serial pc(USBTX,USBRX);
-
+DigitalOut led0(PTD0); //Octavo pin (a partir del botón de RESET).
+DigitalOut led1(PTC4); //Noveno pin.
+DigitalOut led2(PTC12); //Decimo pin.
+DigitalOut led3(PTC3); //Onceavo pin (inicia en el nuevo carril). 
+Timer crono;
 
 int main(){
-    const int filas=3;
-    const int columnas=3;
-        int matriz [filas][columnas];
-        int i,j;
-        int contador=0;
-        
-    for (i=0;i<filas;i++)
-        {
-                for (j=0;j<columnas;j++)
-                    {   contador = contador+1;
-                        matriz [i][j]=contador;
-                         pc.printf("%d\t", matriz[i][j]);
-                        }
-                        pc.printf("\n");
-                    }
-        
-       
+    led0 = 1;
+    led1 = 1;
+    led2 = 1;
+    led3 = 1;
+    crono.start();
+    for(int i; i < 50; i++){ // Dado que la resolución es de 1.8 grados, se necesitan 200 pasos para completar un giro.
+        led0 = 0;
+        led1 = 1;
+        led2 = 0;
+        led3 = 1;
+        wait(0.1‬);
+        led0 = 0;
+        led1 = 1;
+        led2 = 1;
+        led3 = 0;
+        wait(0.1);
+        led0 = 1;
+        led1 = 0;
+        led2 = 1;
+        led3 = 0;
+        wait(0.1);
+        led0 = 1;
+        led1 = 0;
+        led2 = 0;
+        led3 = 1;
+        wait(0.1);
+    }
+    crono.stop();
+    pc.printf("Tiempo de giro: %f seg", crono.read());
 }
\ No newline at end of file