Hello, I’m building something for competition and I’m somewhat inexperienced new to RobotC. (I’m using Vex 2.0 Cortex with Natural Language PLTW. )
One of my actions was a lever that holds down a switch, the problem is that it makes the task go on forever. I tried fixing this by putting a condition in the while loop but it just breaks the code. So now, I tried making a timer that waits about 90 seconds although I think it’s pretty risky, since I only have a tiny amount of time to start it and I’m not sure if it’s supposed to be ready before competition.
Any help? I believe the only options is either figuring out how to end a task if the limit switch hasn’t been released or making a timer AFTER the task was started. Here’s my code:
task slider()
{
startMotor(Motor1, -15);
wait(34);
startMotor(Motor1, 15);
wait(32);
stopMotor(Motor1);
}
task fan()
{
startMotor(Motor2,55);
startMotor(Motor3,55);
wait(5);
stopMotor(Motor2);
stopMotor(Motor3);
}
task checkSensors()
{
repeat(forever)
{
if (SensorValue(Switch1))
{
startTask(slider);
}
if (SensorValue(Switch2))
{
startTask(fan);
}
}
}
task main()
{
startTask(checkSensors);
wait(80);
stopTask(checkSensors);
}
Sorry if it’s not inside a box and that it’s not a image, I just signed up. Again. I would really appreciate any help.