Recent Changes - Search:

TEAMS Academy Wiki

THS

Explore TEAMS!
for visiting sophomores & juniors


Robotics


EnvBioTech

Bat Design

Assistive Tech

Students

Instructors

TEAMS Forum

TEAMS Calendar

TEAMS Web Site

Wiki Info

edit Robots.SideBar

HuntMurphyFindlight

// find THE light
void findlight (void)

	{
	 cr8_adc_enable(ADC_CENTER_1);
	 cr8_adc_enable(ADC_CENTER_2);
	 cr8_adc_enable(ADC_LEFT_1);
	 cr8_adc_enable(ADC_LEFT_2);
	 while (intime) && (safe))
		{
		 cr8_update(cr8);
		 while ((cr8->adc_center2<100) && (safe) && (intime) && (!cr8->bumper_right) && (!cr8->bumper_left))
		        {
		         cr8_drive_direct(cr8->adc_center1, cr8->adc_center2);
			 blink_display (cr8->adc_center1, 0, cr8->adc_center2, 0);
			 lightmeter = cr8->adc_center2;
			 cr8_update(cr8);
		        }
		 if (((cr8 -> bumper_right) || ((cr8 -> bumper_right) && (cr8 -> bumper_left))) && (safe) && (intime)) rightbumper(); 
	         if ((cr8 -> bumper_left) && (!cr8 -> bumper_right) && safe && intime) leftbumper(); 
		 while ((cr8->adc_center2>100) && (cr8->adc_center2 > lightmeter) && (safe) && (intime))
			{
		         cr8_drive_direct(100,100);
			 if (((cr8 -> bumper_right) || ((cr8 -> bumper_right) && (cr8 -> bumper_left))) && (safe) && (intime)) spin(-50,50); 
	                 if ((cr8 -> bumper_left) && (!cr8 -> bumper_right) && safe && intime) spin(50,-50); 
			 lightmeter = cr8->adc_center2;
			 cr8_update(cr8);
		        }
		 if(cr8->adc_center2 < lightmeter) spin(-50,50);
		 if((cr8->adc_center1> 540) && (cr8->adc_center2> 140) && (safe) && (intime) && (!cr8->bumper_right) && (!cr8->bumper_left))
			{
			 cr8_drive(0,0);
			 return;
			}
		}
	}


_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
// spin until you find brighter light
void spin (int l, int r)

	{
	 cr8_adc_enable(ADC_CENTER_1);
	 cr8_adc_enable(ADC_CENTER_2);
	 cr8_adc_enable(ADC_LEFT_1);
	 cr8_adc_enable(ADC_LEFT_2);
         lightmeter1 = cr8 -> adc_center1;
	 lightmeter2 = cr8 -> adc_center2;
	 while(((cr8->adc_center1<lightmeter1)&&(cr8->adc_center2<lightmeter2))&&(safe)&&(intime))
		{
		 lightmeter1 = cr8->adc_center1;
		 lightmeter2 = cr8->adc_center2;
		 blink_display(cr8->adc_center2, cr8->adc_center1, lighmeter, cr8_stopwatch_time());
		 cr8_drive_direct(l,r);
		 cr8_update(cr8);
		}
	 return;
	}
Edit - History - Print - Recent Changes - Search
Page last modified on January 22, 2009, at 08:32 AM