Cicero Matos
/
Serial_Comm_1
Serial comm (over USB) from mbed example, and formated serial display on Realterm terminal
Diff: main.cpp
- Revision:
- 0:2ca76d3b571d
--- /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"); + } +} +}