Sample Code (Line travel)

Does anyone have a sample algorithm for the autonomous mode (Line travel)? Thanks.

This sample is from the EDU tutorial at: http://www.rec.ri.cmu.edu/education/edubot/2004_content/index.htm


/* This program will track the left side of a dark line. 
For this program to work, an IR Reflective Sensor must 
be attached to Digital I/O Port 6, and must be placed at a 
height where it reads 0 over a dark surface, and some other
number over a light surface. An analog optical sensor may also
be used, but the values in the program must be changed to 
correspond to this light sensor's threshold between light
and dark values. */ 

void Default_Routine(void)/* BEGIN Default_Routine(); */
{ 

	if(rc_dig_in06 == 0)  /* if dark is seen */
		{
		pwm01=pwm03=127; /* turn left motors off */
		pwm02=pwm04=96; /* turn right motors forward slowly */
		}
	else 
		{
		pwm01=pwm03=159; /* turn left motors forward slowly */
		pwm02=pwm04=127; /* turn right motors off */
		}

printf("%d
", rc_dig_in06); /* print light sensor readings */

} /* END Default_Routine(); */
\code]