Cicero Matos
/
Serial_Comm_1
Serial comm (over USB) from mbed example, and formated serial display on Realterm terminal
Revision 0:2ca76d3b571d, committed 2013-12-26
- Comitter:
- strain11
- Date:
- Thu Dec 26 04:26:21 2013 +0000
- Commit message:
- Serial Comm first project
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 2ca76d3b571d main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Dec 26 04:26:21 2013 +0000 @@ -0,0 +1,73 @@ +#include "mbed.h" +//====================================================================================== +Serial pc(USBTX, USBRX); // tx, rx +PwmOut led(LED1); +DigitalOut myled_4(LED4); +//====================================================================================== + + +float brightness = 0.0; + + +int main() { + pc.printf("*************************************************\n"); + pc.printf("PROGRAMA DE TESTE DA COMUNICACAO SERIAL\n"); + //wait(1.5); + pc.printf("25-12-2013 - VERSAO 00\n"); + //wait(1.5); + pc.printf("PROGRAMA REALTERM 20070 NO LADO DO PC\n"); + //wait(1.5); + pc.printf(" \n"); + pc.printf("PRESSSIONE 'u' PARA AUMENTAR O BRILHO DO LED_1\n"); + pc.printf(" \n"); + pc.printf("PRESSSIONE 'd' PARA DIMINUIR O BRILHO DO LED_1\n"); + pc.printf(" \n"); + pc.printf("BRILHO ="); + + pc.printf("%f", brightness); + pc.printf(" \n"); + pc.printf("*************************************************\n"); + +//==================================================================================== + while(1) { + char c = pc.getc(); + if((c == 'u') && (brightness < 0.5)) { + brightness += 0.01; + led = brightness; + pc.printf("VALOR AUMENTADO DE +0,01\n"); + + } + + + if((c == 'd') && (brightness > 0.0)) { + brightness -= 0.01; + led = brightness; + pc.printf("VALOR DIMINUIDO DE -0,01\n"); + + } +//-------------------------------------------------------------------------- + if((c == '1')) { + myled_4= 1; + pc.printf("LED_4 LIGADO\n"); + pc.printf("------------\n"); + goto saida; + } +//------------------------------------------------------------------------- + if((c == '0')) { + myled_4= 0; + pc.printf("LED_4 DESLIGADO\n"); + pc.printf("---------------\n"); + goto saida; + } +//------------------------------------------------------------------------- + pc.printf("BRILHO = "); + pc.printf("%f", brightness); + pc.printf(" \n"); + pc.printf("------------------------\n"); +//------------------------------------------------------------------------- +saida: + { + pc.printf(" \n"); + } +} +}
diff -r 000000000000 -r 2ca76d3b571d mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Dec 26 04:26:21 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/b3110cd2dd17 \ No newline at end of file