Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 #include "mbed.h" 00002 00003 Serial device(PC_10,PC_11); // Puerto serial para comunicar con modulo WIFI 00004 Serial pc(USBTX,USBRX); // Puerto serial para comunicar con la pc 00005 00006 int rxCount = 0; 00007 int rcvFlag = 0; 00008 char rxbuff[64]; 00009 00010 DigitalOut led(LED1); 00011 00012 void sISR() 00013 { 00014 //while (device.readable()) 00015 //{ 00016 rxbuff[rxCount] = device.getc(); // dato recibido se almacena en rxbuff 00017 rxCount++; 00018 //} 00019 00020 if(rxCount >=6) 00021 { 00022 00023 if((rxbuff[0]== 0x53)&&(rxbuff[1]==0x54)) 00024 { 00025 rcvFlag = 1; 00026 } 00027 else 00028 { 00029 memset(rxbuff, '\0', sizeof(rxbuff)); 00030 rxCount = 0; 00031 } 00032 } 00033 } 00034 00035 int main() { 00036 00037 device.baud(9600); // configuramos ambos puertos a 115200 bps 00038 pc.baud(115200); 00039 00040 device.attach(&sISR); // habilita recepcion por interrupcion serial 00041 00042 while(1) 00043 00044 { 00045 00046 if(rcvFlag ==1) 00047 { 00048 led = !led; 00049 device.attach(NULL); 00050 00051 switch(rxbuff[2]) 00052 { 00053 case 1: // leds 00054 { 00055 00056 } 00057 break; 00058 00059 case 2: 00060 { 00061 00062 } 00063 break; 00064 00065 00066 case 3: //slider 00067 { 00068 00069 int d1,d2,d3,val; 00070 00071 d1 = rxbuff[3]-48; 00072 d2 = rxbuff[4]-48; 00073 d3 = rxbuff[5]-48; 00074 00075 val = (d1*100)+(d2*10)+d3; 00076 00077 00078 00079 pc.printf("%d\r\n",val); 00080 } 00081 break; 00082 00083 00084 default:break; 00085 } 00086 00087 00088 00089 00090 memset(rxbuff, '\0', sizeof(rxbuff)); 00091 rxCount = 0; 00092 rcvFlag = 0; 00093 device.attach(&sISR); // habilita recepcion por interrupcion serial 00094 00095 } 00096 00097 } 00098 }
Generated on Fri Jul 15 2022 20:51:11 by
1.7.2