XBee-mbed sample

Dependencies:   mbed XBee

Revision:
4:46e91d6f0b26
Parent:
2:505c58df1f94
--- a/main.cpp	Wed Dec 18 02:32:57 2013 +0000
+++ b/main.cpp	Fri Mar 08 18:08:37 2019 +0000
@@ -1,24 +1,34 @@
 #include "mbed.h"
 #include "XBee.h"
 
+BusIn joy(p15,p12,p13,p16);
+DigitalIn fire(p14);
+DigitalOut rstxbee(p30);
+
 DigitalOut myled(LED1);
-XBee xbee(p13, p14);
-XBeeAddress64 remoteAddress = XBeeAddress64(0x0013A200, 0x40319F25);
+Serial xbee(p9, p10);
+Serial pc(USBTX,USBRX);
+//XBeeAddress64 remoteAddress = XBeeAddress64(0x0013A200, 0x40319F25);
 
+unsigned int vv;
+unsigned char nfire,ofire;
 int main() {
-    uint8_t Cmd[] = {'D', '4'};
+ /*   uint8_t Cmd[] = {'D', '4'};
     uint8_t Low[] = {0x04};
     uint8_t High[] = {0x05};
     RemoteAtCommandRequest remoteAtRequest;
-
-    wait(1);
-    xbee.begin(9800);
+*/
+    rstxbee=0;
+    wait(0.001);
+    rstxbee=1;  
+    wait(1.5);
+/*    xbee.begin(9800);
 
     remoteAtRequest = RemoteAtCommandRequest(remoteAddress, Cmd, Low, sizeof(Low));
     remoteAtRequest.setApplyChanges(true);
-
+*/
     while(1) {
-        myled = 1;
+ /*       myled = 1;
         remoteAtRequest.setCommandValue(Low);
         remoteAtRequest.setCommandValueLength(sizeof(Low));
         xbee.send(remoteAtRequest);
@@ -30,6 +40,19 @@
         remoteAtRequest.setCommandValueLength(sizeof(High));
         xbee.send(remoteAtRequest);
         myled = 0;
-        wait(1);
+        wait(1);*/
+        nfire = fire;
+        wait(0.001);
+      //  pc.printf("VAL %u\t%u\n",(unsigned)nfire,(unsigned)ofire);
+        if((ofire!=nfire)) {
+                if(nfire==1){
+                        xbee.printf("%u\r",vv);
+                        pc.printf("%u\r",vv);
+                        vv++;
+                }
+                ofire=nfire;
+                
+        }
+        
     }
 }