XBee-mbed sample

Dependencies:   mbed XBee

Files at this revision

API Documentation at this revision

Comitter:
bouaziz
Date:
Fri Mar 08 18:08:37 2019 +0000
Parent:
3:f5c84899f4d1
Commit message:
test

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r f5c84899f4d1 -r 46e91d6f0b26 main.cpp
--- 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;
+                
+        }
+        
     }
 }