I want to built a remote controlled robot platform and send simple (forward, backward, left , right stop) data to the Platform using a XBEE
This is what I came up with
Transmitter:
int UD = 0;
int LR = 0;
int outByte;
void setup()
{
Serial.begin(9600);
}
void loop() {
UD = analogRead(A0);
LR = analogRead(A1);
//If joystick is Centre
if (UD >= 510 && UD <= 520 && LR >= 520 && LR <= 530)
{
outByte = 'S';
}
//If joystick is Up
if (UD >= 521 && LR >= 520 && LR <= 530)
{
outByte = 'F';
}
//If joystick is down
if (UD <= 509 && LR >= 520 && LR <= 530)
{
outByte = 'B';
}
//If joystick is left
if (UD >=510 && UD <= 520 && LR <= 519)
{
outByte = 'L';
}
//If joystick is right
if (UD >=510 && UD <= 520 && LR >= 531)
{
outByte = 'R';
}
Serial.print(outByte);
}
And this is for the receiver site:
int UD = 0;
int LR = 0;
int outByte;
void setup()
{
Serial.begin(9600);
}
void loop() {
UD = analogRead(A0);
LR = analogRead(A1);
//If joystick is Centre
if (UD >= 510 && UD <= 520 && LR >= 520 && LR <= 530)
{
outByte = 'S';
}
//If joystick is Up
if (UD >= 521 && LR >= 520 && LR <= 530)
{
outByte = 'F';
}
//If joystick is down
if (UD <= 509 && LR >= 520 && LR <= 530)
{
outByte = 'B';
}
//If joystick is left
if (UD >=510 && UD <= 520 && LR <= 519)
{
outByte = 'L';
}
//If joystick is right
if (UD >=510 && UD <= 520 && LR >= 531)
{
outByte = 'R';
}
Serial.print(outByte);
}
The data does not seem to get to the motor controller.
I tested the joystick with a sample sketch : works
I tested the motor shield : works
I tested the XBee's transmitting simple setup: http://arduino.cc/en/Guide/ArduinoWirelessShieldS2 works
When I Hook the transmitter to the serial monitor I get the good values.
What did i do wrong?