/* remote.nqc
 * 
 * This is the remote control part of a remote-controlled robot. It
 * uses a rotation sensor for a steering wheel, and touch sensors for
 * an on-off switch and a forward-reverse switch.
 *
 * For use with "robot.nqc".
 *
 * All code copyright 2003 Rachel Gockley (rgockley@andrew.cmu.edu).
 * Feel free to use it as you wish, but please let me know if you do!
 */

#include "remotecomm.nqh"

#define STEERING SENSOR_1
#define ON_OFF   SENSOR_2
#define DIR      SENSOR_3

task main() {
  int turn, on, dir;

  SetSensor(STEERING, SENSOR_ROTATION);
  SetSensor(ON_OFF, SENSOR_TOUCH);
  SetSensor(DIR, SENSOR_TOUCH);
  SetTxPower(TX_POWER_HI);

  ClearSensor(STEERING);

  while (1) {
    turn = STEERING;

    if (ON_OFF == 1)
      on = GO;
    else
      on = STOP;

    if (DIR == 1)
      dir = FWD;
    else
      dir = REV;

    SendCommandPacket(on, dir, turn);
    //    LookForACK();
    Wait(5);
  }
}