Delayed response to input

Hey Everyone,

I recently finished my senior design, and for our project we had controlled and RC car with hand motions from a glove. We used two bluesmirf bluetooth modems for the wireless communication at 115200 bps. For my partner and I, it was our first real experience with microcontrollers, and the arduino in particular. We managed to get the car to respond how we wanted to the hand motions, but only for a minute or so, then the response of the car would start to be delayed by quite a few seconds. If we powered off the glove or the car, the car would respond properly as soon as another connection was made, but then again after a little bit of time the delay would come back. The bluetooth modems were configured to autoconnect to each other. I have attached the code for both the glove and the car. I would appreciate it if someone could look at it and let me know there thoughts on why this delay may be happening. As I stated before we are already done with the senior design, but i do want to fix this so my kids can enjoy it. Thanks .

Started with getdata in car.txt. After I took some time to fix all the indentation and curly braces to figure out the code, I can see one issue. If you lose one byte, your sync characters will not line up properly and you will ignore them. You will then have to wait for more bytes to get lost before you resync. I would suggest a frame sync byte at the start of the message like 0x5A. If you do not get that, read byte at a time till you do. Then the next byte should be your first sync character. If not, go back and hunt for a new frame sync character. You will also need to arrange the glove to send data and some rate, not when asked by the car sending a byte. If the glove streams data at perhaps 4Hz, and you have a good state machine to parse the incoming data, you should not have delays.

I’ll give that a try. Thanks