///////////////////////////////////////////////////////////////////////////////////////
//
//    Program to Demonstrate Precise Positional Control of a NXT motor using RobotC
//
// This example will loop continuously rotating a motor 6 degrees. The movement is very
// precise +/- 1 degree) with absolutely no overshoot. It stops exactly at the targeted
// position
//
// You can best view the motor movement by attaching a beam to the motor output to create
// a shape like the 'hand' on a clock.
//
///////////////////////////////////////////////////////////////////////////////////////
task main()
{
  //
  // These variables are declared as RAM values. This will allow you, in the RobotC
  // interactive real-time debugger to change them and watch the effect on the motor.
  //
  int nMoveSize     = 6;
  int nSpeed        = 50;
  int nDelay        = 600;

  //
  // Setup the motor configuration
  //
  bFloatDuringInactiveMotorPWM = false;

  nMotorEncoder[motorA]       = 0;
  nMotorEncoderTarget[motorA] = 0;

  while (true)
  {
    //
    // Loop continuously moving the motor forward a small increment
    //
    nMotorEncoderTarget[motorA] = nMoveSize; // incremental amount to move motor
    motor[motorA]               = nSpeed;    // motor speed
    wait1Msec(nDelay);                       // wait for action to complete
  }
}