My Code won't Work. Help!

After hitting the first button to start the emergency stop and following programs, it wont start. The program appears to completely stop. I am not sure what the problem is. FYI this is a line following robot.

#pragma config(Sensor, in1,    lineFollowerR,  sensorLineFollower)

#pragma config(Sensor, in2, lineFollowerL, sensorLineFollower)
#pragma config(Sensor, dgtl1, ultrasonic, sensorSONAR_cm)
#pragma config(Sensor, dgtl3, button, sensorTouch)
#pragma config(Sensor, dgtl4, emerge, sensorTouch)
#pragma config(Motor, port2, rightMotor, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port3, leftMotor, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port5, clencher, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port6, arm, tmotorVex393_MC29, openLoop)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//

task emergency()
{
while(1==1)
{
if(SensorValue(emerge) == 1)
{
stopAllTasks();
}
wait1Msec(10);
}
}

task following()
{
while(1==1)
{
startMotor(leftMotor, 30);
startMotor(rightMotor, -30);
if(SensorValue(lineFollowerR)<1000)
{
startMotor(leftMotor, 40);
wait(.5);
}
if(SensorValue(lineFollowerL)<1000)
{
startMotor(rightMotor, -40);
wait(.5);
}
if(SensorValue(ultrasonic) < 20 && SensorValue(ultrasonic) > 1)
{
stopMotor(leftMotor);
stopMotor(rightMotor);
waitUntil(SensorValue(ultrasonic) > 20);
}
wait1Msec(10);
}
}

task main()
{
untilBump(button);
startTask(following);
startTask(emergency);
}

what language is that

Welcome to the forum!

For future reference, I highly recommend you use code tags to make it much easier for others to read as well as for formatting purposes, which you can do by starting the code with [code] and ending it with [/code]. It would look like this:

#pragma config(Sensor, in1,    lineFollowerR,  sensorLineFollower)
#pragma config(Sensor, in2, lineFollowerL, sensorLineFollower)
#pragma config(Sensor, dgtl1, ultrasonic, sensorSONAR_cm)
#pragma config(Sensor, dgtl3, button, sensorTouch)
#pragma config(Sensor, dgtl4, emerge, sensorTouch)
#pragma config(Motor, port2, rightMotor, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port3, leftMotor, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port5, clencher, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port6, arm, tmotorVex393_MC29, openLoop)
//*!!Code automatically generated by ‘ROBOTC’ configuration wizard !!*//

task emergency()
{
while(1==1)
{
if(SensorValue(emerge) == 1)
{
stopAllTasks();
}
wait1Msec(10);
}
}

task following()
{
while(1==1)
{
startMotor(leftMotor, 30);
startMotor(rightMotor, -30);
if(SensorValue(lineFollowerR)<1000)
{
startMotor(leftMotor, 40);
wait(.5);
}
if(SensorValue(lineFollowerL)<1000)
{
startMotor(rightMotor, -40);
wait(.5);
}
if(SensorValue(ultrasonic) < 20 && SensorValue(ultrasonic) > 1)
{
stopMotor(leftMotor);
stopMotor(rightMotor);
waitUntil(SensorValue(ultrasonic) > 20);
}
wait1Msec(10);
}
}

task main()
{
untilBump(button);
startTask(following);
startTask(emergency);
}

This was done in RobotC.

3 Likes

I would Recommend C++ Or Python But You do you
Blocks Is fine but I recommend it less

If this is in ROBOTC chances are they are not using the VEX V5 system, but rather the VEX Cortex. I know there is PROS C++ for the VEX Cortex but ROBOTC is more universally used in high schools due to PLTW and other Engineering platforms using VEX products.

3 Likes