We have two XBee Series 1 and two LilyPad Arduino with ATmega 328. We have connected them all up as we have seen on many other websites and forums.
The code we are using is listed as attachments. Our main script is PocketSquare4.
We want one of the Arduino's LEDs to light up when the other Arduino is within a specified distance from the other (say 5 feet). We downloaded some code from http://www.instructables.com/id/Proximity-Sensing-Pocket-Squares/ and tried to fit it to our needs, as the idea is similar.
We have the LilyPad Arduino connected to six LEDs on ports 5, 6, 7, 8, 9, and 10. 11 is ground.
As the code is written, it should check for signals from the other XBee 3 times in the loop, then send its own packet. It does not currently check for distance as the problem we keep running into is the XBees do not receive each other's packets. We know this because we have set up "display" statements using the function displayOnFor(int, int). With this, we found it only got to the first one in the function findNeighbors(), meaning each call to xbee.getResponse().isAvailable() was false.
We are also not altogether sure that the way we set up the XBee was correct.
Serial.begin(9600);
xbee.setSerial(Serial);
We do know that it is at least reaching the "display" statement in the sendDataToNeighbors() function, so we assume it is sending data; however, we do not know that we correctly formatted the Tx16Response.
Right now, all the whole project does is flash some LEDs to tell us where in the code it is.
Any help would be greatly appreciated. Thank you.
PocketSquare4.zip (57.3 KB)