line tracker

i am using a line tracking program example from RobotC but it runs constantly and doesnt have a time limit. how do i program it to stop ? i want it to do another task on the same program

change the while loop from while(true) to while(whatever condition you want). You could check the timer and use its value as less than some amount of time as your condition.

This is the program, what should i change? Thanks!

task main()
{
wait1Msec(2000);
int threshold = 1000; /* found by taking a reading on both DARK and LIGHT /
(SensorValue(sonarSensor) > 20 || SensorValue(sonarSensor) == -1); /
surfaces, adding them together, then dividing by 2. */
while(true)
{
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -+
displayLCDCenteredString(0, “Light Sensor:”); // Display |
displayLCDPos(1,6); // Sensor |
displayNextLCDNumber(SensorValue(lineTracker)); // Readings |
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -+

	// sensor sees light:
	if(SensorValue(lineTracker) < threshold)
	{
		// counter-steer left:
		motor[leftMotor]  = 63;
		motor[rightMotor] = 0;
  
	}
	// sensor sees dark:
	else
	{
		// counter-steer right:
		motor[leftMotor]  = 0;
		motor[rightMotor] = 63;

Your condition needs to be inside while(), in place of true, not before while().