My setup includes: 2 arduino uno, 2 arduino wireless proto, 2 XBee pro
I am writing my sketches using only the standard library.
The coordinator unit sends numbers 1, 2 and 3. The receiver uses the 1 to indicate the coordinator (“transmitter”) is turned on, uses 2 to detect motion and 3 to indicate motion has ceased. I remotely turn on and off both the coordinator and receiver. I can see the receiver and thereby know I have turned it off. However, I can not easily see the coordinator and verify it is turned off. I am hoping I can find a way of turning off the “transmitter” led when the coordinator is turned off remotely. I thought checking when Serial_available() is less than 0, I could turn off the “transmitter” led. I assumed this would only occur when the coordinator was turned off. I have discovered it happens when the coordinator is turned on. From that point on the “transmitter” led remains off. I don’t understand why this is true. From what I can see the coordinator continues to send all the numbers I expect. I thought the receiver’s buffer would be filled all of the time. I guessing it empties for short periods between the transmission of data, thereby turning off the led when it should not. I want it turned off only when the coordinator is turned off. When the buffer empties, maybe the sketch should see if the “transmitter” led is turned on and if it is then turn it off only after several seconds have elapsed, like when checking for motion cessation.
What I have learned is Serial_available() is greater than 0 when there is data in the buffer and Serial_read() reads serially the bytes in the buffer and is -1 when there is nothing to read.
Maybe another approach is available. Is there any way that the coordinator can be interrogated for a turned off state. Can I use something other than the cessation of data?