Esclavo

Dependencies:   mbed

Fork of Liditek_Xbee_Esclavo by Raciel Flores Benítez

Committer:
Sumobot
Date:
Fri Mar 03 06:06:49 2017 +0000
Revision:
0:7c8a05b383cd
Esclavo

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Sumobot 0:7c8a05b383cd 1 #include "mbed.h"
Sumobot 0:7c8a05b383cd 2
Sumobot 0:7c8a05b383cd 3 Serial Pc(USBTX, USBRX);
Sumobot 0:7c8a05b383cd 4 Serial xbee(p9, p10);
Sumobot 0:7c8a05b383cd 5 DigitalOut myled(LED1);
Sumobot 0:7c8a05b383cd 6 DigitalOut myled2(LED2);
Sumobot 0:7c8a05b383cd 7 DigitalOut myled3(LED3);
Sumobot 0:7c8a05b383cd 8 DigitalOut myled4(LED4);
Sumobot 0:7c8a05b383cd 9 char Str[100],Id[100],Destino[100],dis[100],sub[100];//Var-Buffer(HH:MM:SS,string ,Presion,Modo,Hora,Minuto,Segundo,Ciclos
Sumobot 0:7c8a05b383cd 10 //&&&&&&&&&&&&&&&&&&&&&&&&&&&&Variables Presion temperatura&&&&&&&&&&&&&&&&&&&&&&&&
Sumobot 0:7c8a05b383cd 11 int dis_S, sub_S;
Sumobot 0:7c8a05b383cd 12
Sumobot 0:7c8a05b383cd 13 int main() {
Sumobot 0:7c8a05b383cd 14 while(1) {
Sumobot 0:7c8a05b383cd 15 xbee.scanf("%s",Str); // Esperando Informacion de la pantalla
Sumobot 0:7c8a05b383cd 16 Pc.printf("%s\n\r",Str); // Impresion de informacion Mandada
Sumobot 0:7c8a05b383cd 17 Pc.printf("Recibido\n\r"); // Mensaje de estado
Sumobot 0:7c8a05b383cd 18 strcpy(Id, strtok(Str , "."));
Sumobot 0:7c8a05b383cd 19 strcpy(Destino, strtok(NULL , ","));
Sumobot 0:7c8a05b383cd 20 strcpy(dis, strtok(NULL, ":"));
Sumobot 0:7c8a05b383cd 21 strcpy(sub, strtok(NULL, "\n"));
Sumobot 0:7c8a05b383cd 22 dis_S = atof(dis);sub_S = atof(sub);
Sumobot 0:7c8a05b383cd 23
Sumobot 0:7c8a05b383cd 24 if(Id == "E")
Sumobot 0:7c8a05b383cd 25 {
Sumobot 0:7c8a05b383cd 26 myled3 = 1;
Sumobot 0:7c8a05b383cd 27 wait(1);
Sumobot 0:7c8a05b383cd 28 }
Sumobot 0:7c8a05b383cd 29 if(dis_S==1)
Sumobot 0:7c8a05b383cd 30 {
Sumobot 0:7c8a05b383cd 31 myled = 1;
Sumobot 0:7c8a05b383cd 32 wait(1);
Sumobot 0:7c8a05b383cd 33 }
Sumobot 0:7c8a05b383cd 34 if(dis_S==0)
Sumobot 0:7c8a05b383cd 35 {
Sumobot 0:7c8a05b383cd 36 myled = 0;
Sumobot 0:7c8a05b383cd 37 wait(1);
Sumobot 0:7c8a05b383cd 38 }
Sumobot 0:7c8a05b383cd 39 if(sub_S==1)
Sumobot 0:7c8a05b383cd 40 {
Sumobot 0:7c8a05b383cd 41 myled2 = 1;
Sumobot 0:7c8a05b383cd 42 wait(1);
Sumobot 0:7c8a05b383cd 43 }
Sumobot 0:7c8a05b383cd 44 if(sub_S==0)
Sumobot 0:7c8a05b383cd 45 {
Sumobot 0:7c8a05b383cd 46 myled2 = 0;
Sumobot 0:7c8a05b383cd 47 wait(1);
Sumobot 0:7c8a05b383cd 48 }
Sumobot 0:7c8a05b383cd 49 }
Sumobot 0:7c8a05b383cd 50 }