Setting up the system:
Adding Xbee endpoints to the system was difficult because they are “dumb.” For Arduino to identify which Xbee was sending, I have Button 1 Xbee connected to pins 0, 1, 2 — Button 2 Xbee to 3, 4, 5 etc. That way, the YUN could send or receive data on a specific pin and the code could identify which Xbee was sending by the pin number:
Pin numbers, oh the pin numbers!
I have the Xbee Explorer USB from Sparkfun. (The red board below) Look at the pins on the right side of the board: DIO12, DIO11… even DIO9 on the other side. Well, these are not DIO pins. Unfortunately, I counted the I/O pins listed on the board (9) which was exactly the pins that I needed! But alas, no that’s not true. On the right, I have a picture of the Parallax USB Adapter Board, which seems to have an accurate label.
The Parallax board matches the data sheet:
Important things about addressing the radios:
To use the DIO pins, you have to set each one as Input or Output according to the chart (I copied it from the data sheet below on the right.) For example, to set Pin 0 as an Input it would be “ATD03”. Also important is setting the I/O Address, ATIA to FFFF so that all radios listen to I/O from other Radios. I set myself up a big old chart to keep these things straight:
Unfortunately, since Pins 9, 11, and 12 were not actually DIO pins, I can’t program them, and my third button will be on the sidelines until I find a better solution.