I'm trying to figure out how to control a pair of servos using a couple of arduinos and XBees.
This is the code sent from the remote:
void printData(){
Serial.write(255);
Serial.write(lSpeed2Mega);
Serial.write(254);
Serial.write(rSpeed2Mega);
}
and this is the code read by the receiver.
while (!Serial1.available()) {}
if (incomingByte == 255){
x = Serial1.read();
}
if (incomingByte == 254){
y = Serial1.read();
}
}
I think what's happening is that the receiver can't keep up with stream coming from the remote. I've spent a while working on it, and my next ideas are to use a handshake (I really haven't figured out how to do this yet) or to add a delay in the remote to slow down the stream).
If anyone can point me in the right direction, or knows where someone else has successfully done this it would be some help. I got this code from google.
Thanks.