//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#include "P:\Isaac\Multirobot Developement\programs\Xbee Tools Includes\OLDXbeeTools (improved).h"

task main()
{
  InitRS485(); //Initialize the Xbee Radio
  string messageReceived; //String to fill with commands received

  while(true)
  {
    ReceiveString(messageReceived); //Receive new commands
    //Display the received command
    // nxtDisplayString(1, "cmd :%s", messageReceived);

    //If the robot receives a command packaged for Robot 2
    if(StringFind(messageReceived, "R2") >= 0)
    {
      //Find right motor frward
      if (StringFind(messageReceived, "RTLT") >= 0)
      {
        motor[motorB] = 50;
        motor[motorC] = 50;
      }
      //Find right motor off
      if (StringFind(messageReceived, "RTLF") >= 0)
      {
        motor[motorB] = 50;
        motor[motorC] = 0;
      }
      //Find left motor forward
      if (StringFind(messageReceived, "RFLT") >= 0)
      {
        motor[motorB] = 0;
        motor[motorC] = 50;
      }
      //Find left motor off
      if (StringFind(messageReceived, "RFLF") >= 0)
      {
        motor[motorB] = 0;
        motor[motorC] = 0;
      }
    }
  }
}
