Toggling Xbee module IO pins remotely with xbee-arduino

21 views
Skip to first unread message

neematas

unread,
Apr 16, 2021, 10:58:16 AM4/16/21
to xbee-api
Hi,

I just want to make sure I'm doing this the best way, I can't actually check it works at all until next week but I think it works in theory.

What I want to have eventually is two functions, each one toggles a pin low on one Xbee, then another, waits for 100ms then brings the pin high again on one Xbee then the other again - one function does one pin, the other does another in the exact same fashion.

To (hopefully) save some time, assume I've got everything set up as in the RemoteAtCommand example, but as I'm addressing two players I've got two XBeeAddress64 assignments and as I'm also toggling two pins (DIO4 and 12) between low and high output states so I've got those all set up too. Here's the pseudocode overview of what I'm doing in one function, the other differs only in the first line:

remoteAtRequest.setCommand(dio4);
remoteAtRequest.setCommandValue(dioLow);
xbee.send(remoteAtRequest);
remoteAtRequest.setRemoteAddress64(xbeeCAddress);
xbee.send(remoteAtRequest);
delay(100);
remoteAtRequest.setCommandValue(dioHigh);
xbee.send(remoteAtRequest);
remoteAtRequest.setRemoteAddress64(xbeeBAddress);
xbee.send(remoteAtRequest);

The length of the value doesn't change so I'm just setting that once, but is this how I'm supposed to toggle IO pins? Is there a cleaner method? A lot of the documentation links I've found are 404, I also can't connect my Arduino to the coordinator I've got yet so I can't test what I've done works at all. Some of the testing I've done has turned up an interesting result that I'll post about separately but the Arduino does seem to want to send the correct data.
Reply all
Reply to author
Forward
0 new messages