Semi confusing xbee robot communication

Hey everyone, I’m working on a project that has a motor attached to a pot(pot 2) for positional feedback, and a pot (pot 1) that will be the reference for the position of the motor. So what I want to happen, is if I rotate pot 1 to half way it will turn the motor, adjusting pot 2, either forward or backwards, to the position of pot 1. Here comes the tricky part, I want to do it all wirelessly with a Xbee and instead of using 1 reference pot controlling 1 motor, I want 5 pots controlling the position of 5 motors. All I want to know right now is, is it possible and how do I go about doing it, I want to make a sort of pseudo code for it.
Attached is a graphical drawing to help understand. The drawing only contains 1 reference pot, 1 feedback pot, and 1 motor.

Here is what I understand for what my code needs to do.

  1. Read in the value of all 5 reference pots on an analog in pin and store them as variables on arduino 1.
  2. Somehow send those variables through Xbee 1 to Xbee 2 and store them as variables on Arduino 2.
  3. Read in the value of all 5 positional pots on an analog in pin and store them as variables on arduino 2.
  4. Write an If/else chain that loops for each motor that compares the reference pots to the positional pots and making a digital output pin on arduino 2 to go high or low for forward or backwards on the specific motor. I would use two pins for each motor.

If someone could help me figure out how to send the values of the pots from arduino 1 to arduino 2 and be stored as a variable would be very helpful, and please let me know if anything could be done in an easier way.


Arduino-Xbee communication.png

Yes all this is perfectly possible. Just look at the examples for sending and receiving data on the xbee. You need to invent a packet protocol fir your numbers, that is something like a header, a ubique number, followed by the data, maybe in ASCII and finally a check sum. You then send this packet as a series of nytes. At the other end you look at each byte coming in until you spot the header. You then know the next bytes will be the packet you described. Finally calculate what the check sum should be and compare it to the one you recievec. If they are the same you can go ahead and use those numbers for your motors.