Isaac Cruz
/
Practica_5_-_Ejercicio_07
p5e7
Revision 31:080589c1250a, committed 2019-10-31
- Comitter:
- isaacross99
- Date:
- Thu Oct 31 04:24:48 2019 +0000
- Parent:
- 30:f7518060fc89
- Commit message:
- 0
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r f7518060fc89 -r 080589c1250a main.cpp --- a/main.cpp Tue Oct 22 19:20:06 2019 +0000 +++ b/main.cpp Thu Oct 31 04:24:48 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.025); + led0 = 0; + led1 = 1; + led2 = 1; + led3 = 0; + wait(0.025); + led0 = 1; + led1 = 0; + led2 = 1; + led3 = 0; + wait(0.025); + led0 = 1; + led1 = 0; + led2 = 0; + led3 = 1; + wait(0.025); + } + crono.stop(); + pc.printf("Tiempo de giro: %f seg", crono.read()); } \ No newline at end of file