Exemplo n.º 1
0
int kkkk(void)
{
    velocity(255,255);
	forward();
	while(1)
    {
		servo_1(0);
		servo_2(0);
		servo_3(0);
		forward();
       red_read(); //display the pulse count when red filter is selected
	   _delay_ms(500);
	   green_read(); //display the pulse count when green filter is selected
	   _delay_ms(500);
	   blue_read(); //display the pulse count when blue filter is selected
	   _delay_ms(500); 
	   lcd_wr_command(0x01);
	   print_sensor(1,1,3);	//Prints value of White Line Sensor1
	   print_sensor(1,5,2);	//Prints Value of White Line Sensor2
	   print_sensor(1,9,1);	//Prints Value of White Line Sensor3
	   print_sensor(2,1,11);
	   servo_1(100);
	   servo_2(100);
	   servo_3(100);
	   _delay_ms(7000);
	   
    }
}
int scan()//return the color no.
{
	red_read();
	blue_read();
	green_read();
	_delay_ms(100);
	if(!(ADC_Conversion(11)>55 && ADC_Conversion(11)<100))
		return EMPTY;
	
	if (red<threshold && green < threshold && blue < threshold)
	{
			return BLACK;
	}
	else
	{
		if (red > blue)
		{
			if (red > green)
				return RED;
			else
				return GREEN;
		}
		else if (blue > green)
			return BLUE;
		else return GREEN;
	}

}
int main(void)
{
    init_devices();
    lcd_set_4bit();
    lcd_init();
	color_sensor_scaling();
	
	while(1)
    {
       red_read(); //display the pulse count when red filter is selected
	   _delay_ms(500);
	   green_read(); //display the pulse count when green filter is selected
	   _delay_ms(500);
	   blue_read(); //display the pulse count when blue filter is selected
	   _delay_ms(500); 
	   no_filter();//display the pulse count when no filter is selected
	   _delay_ms(500);
    }
}
Exemplo n.º 4
0
//SORTMAN
//MAIN SORTING FUNCTION
//R-0 L-1
int colorCalc()
{
	red_read();
	blue_read();
	green_read();
	if (!(red>threshold && green > threshold && blue > threshold))
		return BLACK;
	else
	{
		if (red > blue)
		{
			if (red > green)
				return RED;
			else
				return GREEN;
		}
		else if (blue > green)
			return BLUE;
		else return GREEN;
	}
}
Exemplo n.º 5
0
int scan()//return the color no.
{
	red_read();
	blue_read();
	green_read();
	if (red<threshold && green < threshold && blue < threshold)
		return BLACK;
	else
	{
		if (red > blue)
		{
			if (red > green)
			return RED;
			else
			return GREEN;
		}
		else if (blue > green)
		return BLUE;
		else return GREEN;
	}
}
Exemplo n.º 6
0
int calcThresh()
{
	int c[4],i;
	
	red_read();
	blue_read();
	green_read();
	for(i=0;i<4;i++)
	c[i]=0;
	for(i=0;i<4;i++)
	{
		//read();
		if(red>green && red>blue)
		if(c[0]>red)
		{
			if(c[3]<red)
			c[3]=red;
		}
		else
		{
			if(c[3]<c[0])
			c[3]=c[0];
			c[0]=red;
		}
		else if(blue>green && red<blue)
		if(c[1]>blue)
		{
			if(c[3]<blue)
			c[3]=blue;
		}
		else
		{
			if(c[3]<c[1])
			c[3]=c[1];
			c[1]=blue;
		}
		else
		if(c[2]>green)
		{
			if(c[3]<green)
			c[3]=green;
		}
		else
		{
			if(c[3]<c[2])
			c[3]=c[2];
			c[2]=green;
		}
		
	}
	int t=c[3];
	
	
	
	lcd_cursor(1,1);  //set the cursor on row 1, column 1
	lcd_string("Threshold"); // Display "Blue Pulses" on LCD
	t+=200;
	lcd_print(2,1,t,5);
	_delay_ms(10000);
	lcd_wr_command(0x01); //Clear the LCD
	lcd((char*)t);
	return t;
}