Esclavo

Dependencies:   mbed

Fork of Liditek_Xbee_Esclavo by Raciel Flores Benítez

Revision:
0:7c8a05b383cd
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Mar 03 06:06:49 2017 +0000
@@ -0,0 +1,50 @@
+#include "mbed.h"
+
+Serial Pc(USBTX, USBRX);
+Serial xbee(p9, p10);
+DigitalOut myled(LED1);
+DigitalOut myled2(LED2);
+DigitalOut myled3(LED3);
+DigitalOut myled4(LED4);
+char Str[100],Id[100],Destino[100],dis[100],sub[100];//Var-Buffer(HH:MM:SS,string ,Presion,Modo,Hora,Minuto,Segundo,Ciclos
+ //&&&&&&&&&&&&&&&&&&&&&&&&&&&&Variables Presion temperatura&&&&&&&&&&&&&&&&&&&&&&&&
+int dis_S, sub_S;
+
+int main() {
+    while(1) {
+        xbee.scanf("%s",Str); // Esperando Informacion de la pantalla
+        Pc.printf("%s\n\r",Str); // Impresion de informacion Mandada
+        Pc.printf("Recibido\n\r"); // Mensaje de estado
+        strcpy(Id,  strtok(Str , "."));
+        strcpy(Destino,   strtok(NULL , ","));
+        strcpy(dis, strtok(NULL, ":"));
+        strcpy(sub, strtok(NULL, "\n"));
+        dis_S = atof(dis);sub_S = atof(sub);
+        
+            if(Id == "E")
+            {
+            myled3 = 1;
+            wait(1);   
+            }
+            if(dis_S==1)
+            {
+            myled = 1;
+            wait(1);
+            }
+            if(dis_S==0)
+            {
+            myled = 0;
+            wait(1);
+            }
+            if(sub_S==1)
+            {   
+            myled2 = 1;
+            wait(1);
+            }
+            if(sub_S==0)
+            {
+            myled2 = 0;
+            wait(1);
+        }   
+    } 
+}
\ No newline at end of file