Gets serial communication from Xbee. Code should be on Coordinator. Will display distance in inches and if anything is within 2ft all BUS leds will illuminate.

Dependencies:   C12832_lcd mbed xbeeLibDannelly

Files at this revision

API Documentation at this revision

Comitter:
dannellyz
Date:
Mon Feb 16 04:56:26 2015 +0000
Commit message:
round 1

Changed in this revision

C12832_lcd.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
xbeeLibDannelly.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r d7df8ffb24da C12832_lcd.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/C12832_lcd.lib	Mon Feb 16 04:56:26 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/dreschpe/code/C12832_lcd/#8f86576007d6
diff -r 000000000000 -r d7df8ffb24da main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Feb 16 04:56:26 2015 +0000
@@ -0,0 +1,54 @@
+#include "mbed.h"
+#include "xbee.h" // Include for xbee code
+#include "C12832_lcd.h" // Include for LCD code
+//For string maniputlation
+#include <string> 
+#include <sstream>
+#include <stdlib.h> //Include for atoi
+
+xbee xbee1(p9,p10,p30); //Initalise xbee_lib varName(rx,tx,reset)
+DigitalOut rst1(p30);
+Serial pc(USBTX, USBRX); //Initalise PC serial comms
+C12832_LCD lcd; //Initialize LCD Screen
+BusOut leds(LED1,LED2,LED3,LED4);
+
+//Code to send strings acsross xbee with xbee.h
+//Code should be on the End Device 
+int main()
+{
+    // reset the xbees (at least 200ns)
+    rst1 = 0;
+    wait_ms(1); 
+    rst1 = 1;
+    wait_ms(1);
+    
+    //Establish a variable to receive data from End Device
+    //Max buffer is 202
+    char receiveData[5];
+    char clean[4]; 
+    //Setup LCD screen
+    lcd.cls();      
+    lcd.locate(0,1);
+    
+    while(1) {
+        //Recieve data from Xbee
+        //Second argument is how many characters to read
+        //If zero it will read sizeof(firstArg)
+        xbee1.RecieveData(receiveData,5);
+        
+        //Clean data by removing leader R with String manipulation
+        strncpy ( clean, receiveData+2, 3);
+
+        //Change value back to floats for possible use later
+        int inches = atoi (clean);
+        
+        //If something is closer than 2ft illumiate BUS leds
+        if(inches < 24){
+            leds = 0xFFFF;
+            }
+        else{leds = 0;}
+        //Echo Locally...
+        pc.printf("Inches: %d\n", inches);
+        lcd.printf("Inches %d\n", inches);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r d7df8ffb24da mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Feb 16 04:56:26 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5
\ No newline at end of file
diff -r 000000000000 -r d7df8ffb24da xbeeLibDannelly.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xbeeLibDannelly.lib	Mon Feb 16 04:56:26 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/dannellyz/code/xbeeLibDannelly/#ea7028edb762