Sending acclerometer data in packets Serially using xbee s2 module

:)Hello...friends....Actually i am using Accelerometer values and buttons..to make glove mouse...The code i have given works fine in teensyduino...a atmel microcontroller which has usb support in wired mode.

1. Now i need to send packets of data from arduino uno microcontroller in mobile station to base station which is teensy via (XBEE s2) modules....
2. Can you please give me program scheme to send packets of data containing accelerometer values.
3. Or give a basic structure of packet data program
s.....And I will be eagerly waiting for ur reply....
Quote
#include <Bounce.h>

const int pinAnalogXInput = 1;
const int pinAnalogYInput = 2;
const int pinAnalogDummyInput = 0;

const int cintMovementThreshold = 18;

const int cintZeroXValue = 328;
const int cintZeroYValue = 328;
const int cintZeroZValue = 328;

const int cintMaxXValue = 396;
const int cintMaxYValue = 396;
const int cintMaxZValue = 396;

const int cintMinXValue = 256;
const int cintMinYValue = 256;
const int cintMinZValue = 256;

const int cintXSign = 1;
const int cintYSign = -1;
const int cintZSign = 1;

const int cintMaxMouseMovement = 10;

const int cintMouseDelay = 8;
const int pinLEDOutput = 6;

Bounce button3 = Bounce(3, 10);
Bounce button4 = Bounce(4, 10);
Bounce button5 = Bounce(5, 10);

byte left=0;
byte middle=0;
byte right=0;

void setup()
{

analogReference( DEFAULT );
pinMode( pinLEDOutput, OUTPUT );
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);

}

void loop()
{

fcnProcessAccelerometer();
delay(cintMouseDelay);
button3.update();
button4.update();
button5.update();
byte anyChange = 0;
if (button3.fallingEdge())
{
left = 1;
anyChange = 1;
}
if (button4.fallingEdge())
{
middle = 1;
anyChange = 1;
}
if (button5.fallingEdge())
{
right = 1;
anyChange = 1;
}
if (button3.risingEdge())
{
left = 0;
anyChange = 1;
}
if (button4.risingEdge())
{
middle = 0;
anyChange = 1;
}
if (button5.risingEdge())
{
right = 0;
anyChange = 1;
}
if (anyChange)
{
Mouse.set_buttons(left, middle, right);
}
}

void fcnProcessAccelerometer()
{

int intMouseXMovement = 0;
int intMouseYMovement = 0;

analogRead( pinAnalogDummyInput );

int intAnalogXReading = analogRead(pinAnalogXInput);
int intAnalogYReading = analogRead(pinAnalogYInput);

if( cintMovementThreshold < abs( intAnalogXReading - cintZeroXValue ) )
{

intMouseXMovement = cintXSign * ( ( ( (float)( 2 * cintMaxMouseMovement ) / ( cintMaxXValue - cintMinXValue ) ) * ( intAnalogXReading - cintMinXValue ) ) - cintMaxMouseMovement );

}
else
{

intMouseXMovement = 0;
}

if( cintMovementThreshold < abs( intAnalogYReading - cintZeroYValue ) )
{

intMouseYMovement = cintYSign * ( ( ( (float)( 2 * cintMaxMouseMovement ) / ( cintMaxYValue - cintMinYValue ) ) * ( intAnalogYReading - cintMinYValue ) ) - cintMaxMouseMovement );

}
else
{

intMouseYMovement = 0;
}

Mouse.move(intMouseXMovement, intMouseYMovement);
}

Please use code tags (the # icon) when posting code - it makes it so much easier to read.

This is a very long piece of code. I think my tolerance ends at 10 or 20 lines.

It sounds like you have a project that works well with a wired USB connection and you want to change to a wireless connection.

I suggest you write some short sketches to learn how to use the wireless system and when you are able to do so, try to add that capability to your larger project.

I don't have any personal experience with the hardware you are using.

...R

Thanx robin.....