// line follow tb
//programming by Chris Paxton, Ron McNeil, Ryan Wnuk-Fink
//***MOTORS***
#define RIGHT_MOTOR a
#define LEFT_MOTOR c
//***SENSORS***
#define LIGHT_SENSOR 3
#define TOUCH_BACK
#define TOUCH_FRONT
int calibrate(int s)
{
int Dark = 0;
int Light = 0;
// Measure dark counts
printf("Put on Dark Line and press stop\n");
beep();
while (stop_button() != 1) {}
Dark = analog(LIGHT_SENSOR);
printf("Dark = %d\n", Dark);
// measure light counts
printf("Put on white surface and press stop\n");
beep();
while (stop_button() != 1) {}
light = analog(LIGHT_SENSOR);
printf("Light = %d\n", Light);
// called the BRAINDEAD for a reason
return((Dark+Light)/2);
}
void main()
{
int Dark = 0;
int Light = 0;
int Average = 0;
Average = calibrate(LIGHT_SENSOR);
// to take over the world, press "ctrl + alt + delete" twice
printf("average = %d\n", Average);
//initialize the motor
//_set_motor(RIGHT_MOTOR, LEFT_MOTOR);
//print comment "place bot on dark"
printf("Place bot on dark.");
beep();
//read sensor & see if dark
/* if analog(LIGHT_SENSOR)>= Average
//if dark, move fd
{
fd (RIGHT_MOTOR);
fd (LEFT_MOTOR);
sleep (1);
//all off
off (RIGHT_MOTOR);
off (LEFT_MOTOR);
//fd w/ right motor
fd (RIGHT_MOTOR);
sleep (.5);
//all off
off (RIGHT_MOTOR);
} */
while (stop_button() == 0)
{
while (touch(TOUCH_FRONT) == 0)
{
//read sensor (dark or light)
if analog (LIGHT_SENSOR)>= Average
{
// if dark, go forward left
fd (LEFT_MOTOR), off (RIGHT_MOTOR);
//words of wisdom from Ronnie: Never heard any...
}//words of wisdom from Chris: Never listen to Ronnie
else//if analog (LIGHT_SENSOR) < Average
{
// if light, go fd right
fd (RIGHT_MOTOR), off (LEFT_MOTOR);
//if you dont want to be reading this, say "BEEP!"
//loop to read sensor
}
}
while touch(TOUCH_BACK) == 0
{
if (analog(LIGHT_SENSOR)>= Average)
{
// about line 97
fd (LEFT_MOTOR), off (RIGHT_MOTOR);
}
else//if analog(LIGHT_SENSOR) < Average
{
fd (RIGHT_MOTOR), off (LEFT_MOTOR);
}
}
}
}
//IC4... i see 4 what???
/* this is the bump program for use later -
//delete the "/*" when using
while (Z == 1{
fd(RIGHT_MOTOR); fd (LEFT_MOTOR);
while (touch (FRONT_TOUCH_SENSOR) == 0)
{
printf ("n/a") ;
}
off (RIGHT_MOTOR) ; off (LEFT_MOTOR) ;
beep () ;
printf ("OUCH!!!!!") ;
{
bk (RIGHT_MOTOR) ; bk (LEFT_MOTOR) ;
sleep (2.0);
}
{ while (touch (BACK_TOUCH_SENSOR) == 0)
{
printf ("") ;
}
off (RIGHT_MOTOR) ; off (LEFT_MOTOR) ;
beep () ;
printf ("OUCH!!!!!") ;
}
}
//*****PROBLEMS WITH ROBOT*****
// Make sure all motors connect w/ wheels
//no z==1 thingy RONNIE!!!
//**************PROBLEMS WITH PROGRAMMERS*********************************
//$TUPIDITY!!!!!!!!!!!!!!!!!!!!
//cat smell fer beens & yer mom
//aloha, my asian brother.
//stoopid bilders
// weer messd upp