describe una lectura analogica basica YUNA SALIDA ANALOGA ADEMAS HAY CONECION POR SERIAL CON EL PC
Fork of lecturaAnaloga by
main.cpp@3:19594b07824c, 2015-09-28 (annotated)
- Committer:
- tony63
- Date:
- Mon Sep 28 23:58:26 2015 +0000
- Revision:
- 3:19594b07824c
- Parent:
- 2:7d8925e51f85
revision con comunicacion serie entrando y saliendo en analogo
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tony63 | 0:fd817c22d584 | 1 | // ejemplo lectura analoga |
tony63 | 0:fd817c22d584 | 2 | // EJEMPLO CON UN LCD PARA EL MODULO FRDM-KL25Z PARA LECTURA ANALOGA |
tony63 | 2:7d8925e51f85 | 3 | //y enviar al pc por puerto serial |
tony63 | 0:fd817c22d584 | 4 | |
tony63 | 0:fd817c22d584 | 5 | #include "mbed.h" |
tony63 | 0:fd817c22d584 | 6 | #include "TextLCD.h" |
tony63 | 2:7d8925e51f85 | 7 | Serial pc(USBTX,USBRX); //puertos del PC |
tony63 | 0:fd817c22d584 | 8 | AnalogIn Vin(PTC2); |
tony63 | 1:d4b9822b8df4 | 9 | TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5); // rs, e, d4-d7 |
tony63 | 3:19594b07824c | 10 | int SalidaAnaloga; |
tony63 | 3:19594b07824c | 11 | AnalogOut u(PTE30); |
tony63 | 3:19594b07824c | 12 | float c; |
tony63 | 3:19594b07824c | 13 | |
tony63 | 0:fd817c22d584 | 14 | |
tony63 | 0:fd817c22d584 | 15 | int main( ){ |
tony63 | 3:19594b07824c | 16 | while(1){ |
tony63 | 3:19594b07824c | 17 | pc.scanf("%f", &c); |
tony63 | 3:19594b07824c | 18 | lcd.locate(0,0); |
tony63 | 3:19594b07824c | 19 | lcd.printf("Volt(%f)", Vin.read()); |
tony63 | 3:19594b07824c | 20 | lcd.locate(0,1); |
tony63 | 3:19594b07824c | 21 | lcd.printf("Vout(%f)",c); |
tony63 | 3:19594b07824c | 22 | pc.printf("%f\n",Vin.read()); |
tony63 | 3:19594b07824c | 23 | u.write(c); |
tony63 | 0:fd817c22d584 | 24 | |
tony63 | 2:7d8925e51f85 | 25 | wait(0.1); |
tony63 | 0:fd817c22d584 | 26 | } |
tony63 | 0:fd817c22d584 | 27 | } |