Esclavo

Dependencies:   mbed

Fork of Liditek_Xbee_Esclavo by Raciel Flores Benítez

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 Serial Pc(USBTX, USBRX);
00004 Serial xbee(p9, p10);
00005 DigitalOut myled(LED1);
00006 DigitalOut myled2(LED2);
00007 DigitalOut myled3(LED3);
00008 DigitalOut myled4(LED4);
00009 char Str[100],Id[100],Destino[100],dis[100],sub[100];//Var-Buffer(HH:MM:SS,string ,Presion,Modo,Hora,Minuto,Segundo,Ciclos
00010  //&&&&&&&&&&&&&&&&&&&&&&&&&&&&Variables Presion temperatura&&&&&&&&&&&&&&&&&&&&&&&&
00011 int dis_S, sub_S;
00012 
00013 int main() {
00014     while(1) {
00015         xbee.scanf("%s",Str); // Esperando Informacion de la pantalla
00016         Pc.printf("%s\n\r",Str); // Impresion de informacion Mandada
00017         Pc.printf("Recibido\n\r"); // Mensaje de estado
00018         strcpy(Id,  strtok(Str , "."));
00019         strcpy(Destino,   strtok(NULL , ","));
00020         strcpy(dis, strtok(NULL, ":"));
00021         strcpy(sub, strtok(NULL, "\n"));
00022         dis_S = atof(dis);sub_S = atof(sub);
00023         
00024             if(Id == "E")
00025             {
00026             myled3 = 1;
00027             wait(1);   
00028             }
00029             if(dis_S==1)
00030             {
00031             myled = 1;
00032             wait(1);
00033             }
00034             if(dis_S==0)
00035             {
00036             myled = 0;
00037             wait(1);
00038             }
00039             if(sub_S==1)
00040             {   
00041             myled2 = 1;
00042             wait(1);
00043             }
00044             if(sub_S==0)
00045             {
00046             myled2 = 0;
00047             wait(1);
00048         }   
00049     } 
00050 }