When compiling code, we get the following error:
Error:Task ‘usercontrol’ is not defined at global scope level
#pragma config(Sensor, in6, armPot, sensorAnalog)
#pragma config(Sensor, dgtl1, frontBumper, sensorTouch)
#pragma config(Sensor, dgtl2, backBumper, sensorNone)
#pragma config(Sensor, dgtl3, sonarSensor, sensorSONAR_cm)
#pragma config(Sensor, dgtl5, frontLimit, sensorTouch)
#pragma config(Motor, port1, leftMotor, tmotorVex393, openLoop, reversed)
#pragma config(Motor, port6, clawMotor, tmotorVex393, openLoop)
#pragma config(Motor, port7, armMotor, tmotorVex393, openLoop)
#pragma config(Motor, port10, rightMotor, tmotorVex393, openLoop)
#pragma platform(VEX)
//Competition Control and Duration Settings
#pragma competitionControl(Competition)
#pragma autonomousDuration(30)
#pragma userControlDuration(120)
#include "Vex_Competition_Includes.c" //Main competition background code...do not modify!
/////////////////////////////////////////////////////////////////////////////////////////
//
// Pre-Autonomous Functions
//
// You may want to perform some actions before the competition starts. Do them in the
// following function.
//
/////////////////////////////////////////////////////////////////////////////////////////
void pre_auton()
{
// Set bStopTasksBetweenModes to false if you want to keep user created tasks running between
// Autonomous and Tele-Op modes. You will need to manage all user created tasks if set to false.
bStopTasksBetweenModes = true;
// 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()
{
while (vexRT [Btn7D] == 0)
while (1==1)
if (SensorValue(sonarSensor) > 20 || SensorValue(sonarSensor) == -1) // Loop while robot's Ultrasonic sensor is further than 20 inches away from an object
{ // || (or) it is '-1'. (-1 is the value returned when nothing is in it's visable range)
motor[rightMotor] = 63; // Motor on port2 is run at half (63) power forward
motor[leftMotor] = 63; // Motor on port3 is run at half (63) power forward
}
else
{
motor [rightMotor] = 0;
motor [leftMotor] = 0;
wait1Msec(1000);
motor [rightMotor] = - 63;
motor [leftMotor] = - 63;
wait1Msec (1000);
motor [rightMotor] = 63;
motor [leftMotor] = -63;
wait1Msec (1000);
}
/////////////////////////////////////////////////////////////////////////////////////////
//
// 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 usercontrol()
{
while (vexRT [Btn7D] == 0)
{
}
// User control code here, inside the loop
while (true)
{
wait1Msec(1000); // Robot waits for 1000 milliseconds before executing program
if(SensorValue(sonarSensor) > 5 || SensorValue(sonarSensor) < 0) // Loop while robot's Ultrasonic sensor is further than 4 inches away from an object
{ // || (or) it is '-1'. (-1 is the value returned when nothing is in it's visable range)
motor[rightMotor] = 127; // Motor on port2 is run at half (63) power forward
motor[leftMotor] = 127; // Motor on port3 is run at half (63) power forward
if(SensorValue(sonarSensor) < 5)
{
motor[rightMotor] = 0;
motor[leftMotor] = 63;
wait1Msec(2000);
}
}
// Move forward at full power
motor[leftMotor] = 127; // Motor on port1 is run at full (127) power forward
motor[rightMotor] = 127; // Motor on port10 is run at full (127) power forward
wait1Msec(2000);
while(1 == 1)
{
//Driving Motor Control - joystick remote control
motor[leftMotor] = vexRT[Ch3] ; // Left Joystick Y value
motor[rightMotor] = vexRT[Ch2] ; // Right Joystick Y value
//Arm Control
if(vexRT[Btn6U] == 1 && SensorValue [armPot] <4092)
{
motor[armMotor] = 60;
}
else if(vexRT[Btn6D] == 1 && SensorValue[frontLimit] == 0)
{
motor[armMotor] = -60;
}
else
{
motor[armMotor] = 0;
//Claw Control
if(vexRT[Btn5U] == 1)
{
motor[clawMotor] = 30;
}
else if(vexRT[Btn5D] == 1)
{
motor[clawMotor] = -30;
}
else
{
motor[clawMotor] = 0;
}
}
}
}
}
}
Please help! We compete this Saturday.