Code to send all the data from the mbed application board.

Dependencies:   mbed

Committer:
dannellyz
Date:
Sun Apr 19 19:36:23 2015 +0000
Revision:
0:d07e1be874a3
code to send app board info with xbee

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dannellyz 0:d07e1be874a3 1 // Example of formulating a string to send all appBaord data serial over XBEE
dannellyz 0:d07e1be874a3 2 /******************Declaration of necessary libraries and objects************************/
dannellyz 0:d07e1be874a3 3 #include "mbed.h"
dannellyz 0:d07e1be874a3 4 BusIn joy(p15,p12,p13,p16); //Initialize joystick bus
dannellyz 0:d07e1be874a3 5 AnalogIn pot1(p19); //Potentiometer 1
dannellyz 0:d07e1be874a3 6 AnalogIn pot2(p20); //Potentiometer 2
dannellyz 0:d07e1be874a3 7 Serial pc(USBTX, USBRX); //Initialize PC serial comms
dannellyz 0:d07e1be874a3 8 Serial xbeeOut(p9, p10); //tx, rx via Xbee socket
dannellyz 0:d07e1be874a3 9 int main() {
dannellyz 0:d07e1be874a3 10 /******************While loop call to run code indefinitely******************************/
dannellyz 0:d07e1be874a3 11 while(1) {
dannellyz 0:d07e1be874a3 12 //This can be customized to take any other internal or external sensors
dannellyz 0:d07e1be874a3 13 int joystick = joy;
dannellyz 0:d07e1be874a3 14 float Lpot = pot1;
dannellyz 0:d07e1be874a3 15 float Rpot = pot2;
dannellyz 0:d07e1be874a3 16 //Echo locally for error checking
dannellyz 0:d07e1be874a3 17 printf("$APPBOARD,%.02f,%.02f,%d\r\n",Lpot,Rpot,joystick);
dannellyz 0:d07e1be874a3 18 //Use the same serial fictions as above the transmit over XBee
dannellyz 0:d07e1be874a3 19 xbeeOut.printf("$APPBOARD,%.02f,%.02f,%d\r\n",Lpot,Rpot,joystick);
dannellyz 0:d07e1be874a3 20 wait(.1);//Short pause to avoid going over the through put
dannellyz 0:d07e1be874a3 21 }//while(1)
dannellyz 0:d07e1be874a3 22 }//main()