xbee receiver

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
nnoitre
Date:
Wed Mar 09 15:04:39 2016 +0000
Commit message:
2 way handshake

Changed in this revision

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
diff -r 000000000000 -r bb9f85e295bf main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Mar 09 15:04:39 2016 +0000
@@ -0,0 +1,63 @@
+#include "mbed.h"
+
+Serial xbee(p9,p10);                //Create serial object
+char a;
+//DigitalOut nReset(p30);             //reset pin of the xbee
+DigitalOut myled1(LED1);
+DigitalOut myled2(LED2);
+DigitalOut myled3(LED3);
+DigitalOut myled4(LED4);
+
+int main(){
+    a=255;
+    myled2=1;
+    xbee.baud(57600);               //set the baud rate of the xbee. (9600 standard)
+    wait(0.2);
+    myled2=0;
+    while(1) {
+        if(xbee.readable()) {       //Checks if the data is readable
+            a = xbee.getc();        //Get the first character that's in the buffer
+            if(a==0) {                //detects if joystick is pressed up
+                myled1=1;
+                xbee.putc(255);
+            }
+            if(a==129) {                //detects if yoystick is pressed down
+                myled1=1;
+                myled2=1;
+                xbee.putc(126);
+            }
+            if(a==66) {                //detects if yoystick is pressed down
+                myled2=1;
+                xbee.putc(189);
+            }
+            if(a==195) {                //detects if yoystick is pressed down
+                myled2=1;
+                myled3=1;
+                xbee.putc(60);
+            }
+            if(a==36) {                //detects if yoystick is pressed down
+                myled3=1;
+                xbee.putc(219);
+            }
+            if(a==165) {                //detects if yoystick is pressed down
+                myled3=1;
+                myled4=1;
+                xbee.putc(90);
+            }
+            if(a==102) {                //detects if yoystick is pressed down
+                myled4=1;
+                xbee.putc(153);
+            }
+            if(a==231) {                //detects if yoystick is pressed down
+                myled4=1;
+                myled1=1;
+                xbee.putc(24);
+            }
+            wait(0.2);
+            myled1=0;
+            myled2=0;
+            myled3=0;
+            myled4=0;
+        }
+    }
+}    
\ No newline at end of file
diff -r 000000000000 -r bb9f85e295bf mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Mar 09 15:04:39 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/87f2f5183dfb
\ No newline at end of file