![](/media/cache/profiles/25a76ba89c58a499eadfd4cb8ecf8af5.jpg.50x50_q85.jpg)
Code to send all the data from the mbed application board.
Diff: main.cpp
- Revision:
- 0:d07e1be874a3
diff -r 000000000000 -r d07e1be874a3 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Apr 19 19:36:23 2015 +0000 @@ -0,0 +1,22 @@ +// Example of formulating a string to send all appBaord data serial over XBEE +/******************Declaration of necessary libraries and objects************************/ +#include "mbed.h" +BusIn joy(p15,p12,p13,p16); //Initialize joystick bus +AnalogIn pot1(p19); //Potentiometer 1 +AnalogIn pot2(p20); //Potentiometer 2 +Serial pc(USBTX, USBRX); //Initialize PC serial comms +Serial xbeeOut(p9, p10); //tx, rx via Xbee socket +int main() { +/******************While loop call to run code indefinitely******************************/ + while(1) { + //This can be customized to take any other internal or external sensors + int joystick = joy; + float Lpot = pot1; + float Rpot = pot2; + //Echo locally for error checking + printf("$APPBOARD,%.02f,%.02f,%d\r\n",Lpot,Rpot,joystick); + //Use the same serial fictions as above the transmit over XBee + xbeeOut.printf("$APPBOARD,%.02f,%.02f,%d\r\n",Lpot,Rpot,joystick); + wait(.1);//Short pause to avoid going over the through put + }//while(1) +}//main()