xBee: duplicate response

Thanks so much for your answers. They really helped!

I've made the changes that you suggested, Jack. I also stripped down the code of any unnecessary lines as Paul Suggested

This fixed my problem completely when I had an LED in place with the relay. However, when I was using a new component with the relay, it went back to repeating itself.

I then tried using a 560ohm resistor, which stopped the repetition, but didn't quite provide enough current for the new component (enough to indicate that it was on, but not enough to make it work). I am going to pick up a couple of lower value resistors, swap them in and pick the one that stops the repetition but provides enough current for the new component. I note that the component wouldn't work with a higher value resistor. Also, the repetition I'm experiencing only happens with relays; putting something else in the circuit doesn't have the same result.

It seems odd to me that this would make any difference!

It would be interesting to know why for future reference. It seems bizarre to me that the resistance within the relay circuit would cause it to turn on and off twice and also register a false 'D'.