Gerardo Carmona
/
10_pot_serial
Send analog input trhough basic serial communication
main.cpp@0:8c463cc04c35, 2013-10-09 (annotated)
- Committer:
- gcarmonar
- Date:
- Wed Oct 09 21:29:47 2013 +0000
- Revision:
- 0:8c463cc04c35
- Child:
- 1:89d58811e089
Ver1.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gcarmonar | 0:8c463cc04c35 | 1 | /* |
gcarmonar | 0:8c463cc04c35 | 2 | - Descripcion - |
gcarmonar | 0:8c463cc04c35 | 3 | Mandar la lectura de un puerto analogico y mandarlo por Serie a la computadora. |
gcarmonar | 0:8c463cc04c35 | 4 | Recuerda que para Windows debes tener instalado el driver de la Freedom y un |
gcarmonar | 0:8c463cc04c35 | 5 | programa que pueda monitorear puertos serie como Teraterm. |
gcarmonar | 0:8c463cc04c35 | 6 | |
gcarmonar | 0:8c463cc04c35 | 7 | Configura Teraterm seleccionando la opcion de Serial y selecciona el puerto COM |
gcarmonar | 0:8c463cc04c35 | 8 | que esta utilizando tu tarjeta (busca dentro del administrador de dispositivos |
gcarmonar | 0:8c463cc04c35 | 9 | el puerto COM). |
gcarmonar | 0:8c463cc04c35 | 10 | |
gcarmonar | 0:8c463cc04c35 | 11 | - AYUDA - |
gcarmonar | 0:8c463cc04c35 | 12 | Serial : Para configurar comunicacion Serie. |
gcarmonar | 0:8c463cc04c35 | 13 | USBTX, USBRX : Configura los puertos (Envio, Recepcion). |
gcarmonar | 0:8c463cc04c35 | 14 | printf : Comando para mandar los datos a traves del puerto COM, se requiere |
gcarmonar | 0:8c463cc04c35 | 15 | especificar que datos, entre " " se pone texto y el tipo de |
gcarmonar | 0:8c463cc04c35 | 16 | variables que se desea enviar. |
gcarmonar | 0:8c463cc04c35 | 17 | %f : Especifica que queremos mandar una variable tipo float. |
gcarmonar | 0:8c463cc04c35 | 18 | \n : Manda un salto de linea. |
gcarmonar | 0:8c463cc04c35 | 19 | */ |
gcarmonar | 0:8c463cc04c35 | 20 | |
gcarmonar | 0:8c463cc04c35 | 21 | #include "mbed.h" |
gcarmonar | 0:8c463cc04c35 | 22 | |
gcarmonar | 0:8c463cc04c35 | 23 | Serial pc(USBTX, USBRX); // tx, rx |
gcarmonar | 0:8c463cc04c35 | 24 | AnalogIn pot(A0); |
gcarmonar | 0:8c463cc04c35 | 25 | |
gcarmonar | 0:8c463cc04c35 | 26 | float potval; |
gcarmonar | 0:8c463cc04c35 | 27 | float potval2; |
gcarmonar | 0:8c463cc04c35 | 28 | |
gcarmonar | 0:8c463cc04c35 | 29 | int main(){ |
gcarmonar | 0:8c463cc04c35 | 30 | while(1){ |
gcarmonar | 0:8c463cc04c35 | 31 | potval = pot; |
gcarmonar | 0:8c463cc04c35 | 32 | potval2 = potval*2; |
gcarmonar | 0:8c463cc04c35 | 33 | pc.printf("El valor del puerto es: %f volts\n", potval); |
gcarmonar | 0:8c463cc04c35 | 34 | wait(1); |
gcarmonar | 0:8c463cc04c35 | 35 | } |
gcarmonar | 0:8c463cc04c35 | 36 | |
gcarmonar | 0:8c463cc04c35 | 37 | } |
gcarmonar | 0:8c463cc04c35 | 38 |