tasks in competition template

I keep getting compile errors when setting up tasks in the competition template. The following code works just fine without the template. Could someone help me figure out where to set up the tasks in the template? Much appreciated.

task drive ()        //driving program to run parallel to lifting and delivering

{
  while (1==1)
  {
  motor[rightMotor] = (vexRT[Ch2]);
  motor[leftMotor] = (vexRT[Ch3]);
  }
}

task conveyer()      /*task conveyor runs the conveyor belt when button 6U is
                      pressed and runs backwards when 6D is pressed*/
{
  while (1==1)
  {
  while (vexRT[Btn6U]==1)
   {
    startMotor(conv1, 127);
    startMotor(conv2, 127);
    }
  while (vexRT[Btn6D]==1)
  {
    startMotor(conv1, -127);
    startMotor(conv2, -127);
  }
  stopMotor(conv1);
  stopMotor(conv2);
  }
}


task main()             //task main is the lifting program
{
  StartTask (drive);
  StartTask (conveyer);
  SensorValue[encoder] = 0;

  while(1==1)
  {
 while(vexRT[Btn5U] == 1)              //high goal
      {
        if(SensorValue[encoder]<=1200)      //holding pattern for high goal
        {
          startMotor(lift1,127);
          startMotor(lift2, 127);
        }
        else
        {
          stopMotor(lift1);
          stopMotor(lift2);
        }
      }
  while(vexRT[Btn7U] == 1)               //go to medium goal
      {
        if(SensorValue[encoder]<=800)      //holding pattern for medium goal
        {
          startMotor(lift1,127);
          startMotor(lift2, 127);
        }
        else
        {
          stopMotor(lift1);
          stopMotor(lift2);
        }
      }
while(vexRT[Btn7L] == 1)                  //go to low goal
      {
        if(SensorValue[encoder]<=360)      //holding pattern for high goall
        {
          startMotor(lift1,127);
          startMotor(lift2,127);
        }
        else
        {
          stopMotor(lift1);
          stopMotor(lift2);
        }
      }

while (vexRT[Btn5D] == 1)               //lower the lift
      {
        startMotor(lift1, -50);
        startMotor(lift2, -50);
        SensorValue[encoder] = 0;
      }

      stopMotor(lift1);
      stopMotor(lift2);
      SensorValue[encoder] = 0;
}                                           //end of forever loop
}                                           //end of task main

The usercontrol seems to work fine but the autonomous doesn’t run. Am I missing a setting? It takes me straight to usercontrol. Suggestions?

The autonomous program is a dummy program at this point but I can tell that it isn’t running because of debugger feedback. I have attached the entire code. Please help, competition tomorrow :eek:


#pragma config(Sensor, dgtl1,  encoder,             sensorQuadEncoder)
#pragma config(Motor,  port2,           rightMotor,    tmotorNormal, openLoop)
#pragma config(Motor,  port3,           leftMotor,     tmotorNormal, openLoop, reversed)
#pragma config(Motor,  port4,           lift1,         tmotorNormal, openLoop)
#pragma config(Motor,  port5,           lift2,         tmotorNormal, openLoop, reversed)
#pragma config(Motor,  port6,           conv1,         tmotorNormal, openLoop)
#pragma config(Motor,  port7,           conv2,         tmotorNormal, openLoop, reversed)
#pragma platform(VEX)
#include "Vex_Competition_Includes.c"   //Main competition background code...do not modify!

//Competition Control and Duration Settings
#pragma competitionControl(Competition)
#pragma autonomousDuration(20)
#pragma userControlDuration(120)


/////////////////////////////////////////////////////////////////////////////////////////
//
//                          Pre-Autonomous Functions
//
// You may want to perform some actions before the competition starts. Do them in the
// following function.
//
/////////////////////////////////////////////////////////////////////////////////////////
void pre_auton()
{
	// All activities that occur before the competition starts
	// Example: clearing encoders, setting servo positions, ...
}


/////////////////////////////////////////////////////////////////////////////////////////
//
//                                 Autonomous Task
//
// This task is used to control your robot during the autonomous phase of a VEX Competition.
// You must modify the code to add your own robot specific commands here.
//
/////////////////////////////////////////////////////////////////////////////////////////

task autonomous()
{
startMotor(lift1,127);    //run two motors for a while and then stop
startMotor(lift2, 127);
wait(10);
stopMotor(lift1);
stopMotor(lift2);   
           
}

/////////////////////////////////////////////////////////////////////////////////////////
//
//                                 User Control Task
//
// This task is used to control your robot during the user control phase of a VEX Competition.
// You must modify the code to add your own robot specific commands here.
//
/////////////////////////////////////////////////////////////////////////////////////////
task drive ()        //driving program to run parallel to lifting and delivering

{
  while (1==1)
  {
  motor[rightMotor] = (vexRT[Ch2]);
  motor[leftMotor] = (vexRT[Ch3]);
  }
}

task conveyer()      /*task conveyor runs the conveyor belt when button 6U is
                      pressed and runs backwards when 6D is pressed*/
{
  while (1==1)
  {
  while (vexRT[Btn6U]==1)
   {
    startMotor(conv1, 127);
    startMotor(conv2, 127);
    }
  while (vexRT[Btn6D]==1)
  {
    startMotor(conv1, -127);
    startMotor(conv2, -127);
  }
  stopMotor(conv1);
  stopMotor(conv2);
  }
}



task usercontrol()
{
  StartTask (drive);
  StartTask (conveyer);
  SensorValue[encoder] = 0;

  while(1==1)
  {
    while(vexRT[Btn5U] == 1)              //high goal
      {
        wait1Msec(20);
        if(SensorValue[encoder]<=1200)      //holding pattern for high goal
        {
          startMotor(lift1,127);
          startMotor(lift2, 127);
        }
        else
        {
          stopMotor(lift1);
          stopMotor(lift2);
        }
      }
  while(vexRT[Btn7U] == 1)               //go to medium goal
      {
        wait1Msec(20);
        if(SensorValue[encoder]<=800)      //holding pattern for medium goal
        {
          startMotor(lift1,127);
          startMotor(lift2, 127);
        }
        else
        {
          stopMotor(lift1);
          stopMotor(lift2);
        }
      }
  while(vexRT[Btn7L] == 1)                  //go to low goal
      {
        wait1Msec(20);
      if(SensorValue[encoder]<=360)      //holding pattern for high goall
        {
          startMotor(lift1,127);
          startMotor(lift2,127);
        }
        else
        {
          stopMotor(lift1);
          stopMotor(lift2);
        }
      }

  while (vexRT[Btn5D] == 1)               //lower the lift
      {
        wait1Msec(20);
        startMotor(lift1, -50);
        startMotor(lift2, -50);
        SensorValue[encoder] = 0;
      }

      stopMotor(lift1);
      stopMotor(lift2);
      SensorValue[encoder] = 0;
}                                           //end of forever loop
}        

Hi, welcome to the VEX forum pleeper!

Your robot only starts Autonomous mode when your joystick is plugged into the field or a competition switch. You can also get to a Virtual Competition Switch in ROBOTC by going to the Robot Menu, Debugger Windows, and clicking Competition Control.