Isaac Cruz
/
Ejercicio_POT
Practica 7
Revision 32:69920613d52f, committed 2019-11-29
- Comitter:
- isaacross99
- Date:
- Fri Nov 29 15:35:38 2019 +0000
- Parent:
- 31:080589c1250a
- Commit message:
- Potenc
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 080589c1250a -r 69920613d52f main.cpp --- a/main.cpp Thu Oct 31 04:24:48 2019 +0000 +++ b/main.cpp Fri Nov 29 15:35:38 2019 +0000 @@ -1,39 +1,14 @@ #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; - +AnalogIn pot(PTB2); +PwmOut led(PTC3); int main(){ - 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()); + float leer, lim; + while(1){ + leer = pot.read_u16(); + lim = leer/65535; + pc.printf("\n%f",lim); + wait(0.2); + led.write(lim); + } } \ No newline at end of file