Joystick for SLVM

Dependencies:   mbed

Revision:
0:636b2ff1fa0b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Dec 09 01:23:36 2014 +0000
@@ -0,0 +1,30 @@
+#include "mbed.h"
+#include "xbee.h"
+
+//Sender code
+
+AnalogIn JS1x(p19);
+AnalogIn JS2x(p20);
+xbee xbee1(p9,p10,p11); //Initalise xbee_lib
+Serial Sender(p9,p10);
+int main()
+{
+    char x1, x2, x3, rr=0x00;
+    while(1) 
+    {             
+
+        if(JS1x<.25) x1= 0x0C;
+        else if(JS1x>.75) x1= 0x03;
+        else x1= 0x00;
+
+        if(JS2x>.75) x2= 0x0C;
+        else if(JS2x<.25) x2= 0x03;
+        else x2= 0x00;
+
+        x3=(x1<<4)|x2;
+        if (x3!=rr)Sender.putc(x3); //just says to only send new commands, can remove if you want
+        rr=x3;
+        
+    }
+}
+