0
$\begingroup$

//ERROR: Task 'autonomous' is not defined at global scope level

#pragma config(StandardModel, "RVW CLAWBOT")
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#pragma DebuggerWindows("joystickSimple")
task autonomous();
task main()

{
while (true)

{


    // update buttons and joysticks
    getJoystickSettings(joystick);

    //Assign the left and right joystick values
    //to the left and right motors
    motor[leftMotor] = joystick.joy1_y1;
    motor[rightMotor] = joystick.joy1_y1;

task autonomous()
  {
    motor[leftMotor] = 80;
    motor[rightMotor] = 80;
    wait1Msec(2500);
    motor[leftMotor] = 0;
    motor[rightMotor] = 0;
    
    wait1Msec(1000);
    
    motor[leftMotor] = 80;
    motor[rightMotor] = -80;
    wait1Msec(2500);
    motor[leftMotor] = 0;
    motor[rightMotor] = 0;
    
  }
    if(motor[rightMotor] == 1) {
    startTask(autonomous);
    stopTask(main);
  
}
}
}
$\endgroup$
1
  • $\begingroup$ your code is badly formatted ... if you use correct indentation, then you may be able to see your error $\endgroup$ – jsotola Sep 26 '20 at 23:52
2
$\begingroup$

The code for “task autonomous()” should be outside of the main() function.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.