I am using the new vexcode iq C++ and when I click on the program on the brain, it says user program has exceeded time limit of 3 seconds. I have tried wiping the brain and redownloading it, getting a new brain, and inserting the code into a different file and downloading that onto the brain and none of them have worked.
Can you post the code ? It sounds like you probably have a while loop that blocks (ie. no wait statement)
3 Likes
using namespace vex;
int main(){
while(true){
leftDrive.spin(vex::directionType::fwd, Controller.AxisA.value(), vex::velocityUnits::pct);
rightDrive.spin(vex::directionType::fwd, Controller.AxisD.value(), vex::velocityUnits::pct);
omni.spin(vex::directionType::fwd, Controller.AxisB.value(), vex::velocityUnits::pct);
omni.spin(vex::directionType::fwd, Controller.AxisC.value(), vex::velocityUnits::pct);
}
if(Controller.ButtonRUp.pressing()){
rightArm.spin(directionType::fwd, 100, velocityUnits::pct);
leftArm.spin(directionType::fwd, 100, velocityUnits::pct);
}
else if(Controller.ButtonRDown.pressing()){
rightArm.spin(directionType::fwd, -100, velocityUnits::pct);
leftArm.spin(directionType::fwd, -100, velocityUnits::pct);
}
else {
rightArm.stop(brakeType::hold);
leftArm.stop(brakeType::hold);
}
if(Controller.ButtonLUp.pressing()){
flingyDingy.spin(directionType::fwd, 100, velocityUnits::pct);
}
else if(Controller.ButtonLDown.pressing()){
flingyDingy.spin(directionType::fwd, -100, velocityUnits::pct);
}
else{
flingyDingy.stop(brakeType::hold);
}
vex::task::sleep(20);
}
yes, you have a misplaced brace after the first four spin calls. It should be this
using namespace vex;
int main(){
while(true){
leftDrive.spin(vex::directionType::fwd, Controller.AxisA.value(), vex::velocityUnits::pct);
rightDrive.spin(vex::directionType::fwd, Controller.AxisD.value(), vex::velocityUnits::pct);
omni.spin(vex::directionType::fwd, Controller.AxisB.value(), vex::velocityUnits::pct);
omni.spin(vex::directionType::fwd, Controller.AxisC.value(), vex::velocityUnits::pct);
// } <-- misplaced brace
if(Controller.ButtonRUp.pressing()){
rightArm.spin(directionType::fwd, 100, velocityUnits::pct);
leftArm.spin(directionType::fwd, 100, velocityUnits::pct);
}
else if(Controller.ButtonRDown.pressing()){
rightArm.spin(directionType::fwd, -100, velocityUnits::pct);
leftArm.spin(directionType::fwd, -100, velocityUnits::pct);
}
else {
rightArm.stop(brakeType::hold);
leftArm.stop(brakeType::hold);
}
if(Controller.ButtonLUp.pressing()){
flingyDingy.spin(directionType::fwd, 100, velocityUnits::pct);
}
else if(Controller.ButtonLDown.pressing()){
flingyDingy.spin(directionType::fwd, -100, velocityUnits::pct);
}
else{
flingyDingy.stop(brakeType::hold);
}
vex::task::sleep(20);
} // <-- should be here
}
5 Likes