int main() { init_devices(); lcd_set_4bit(); lcd_init(); color_sensor_scaling();/* threshold= calcThresh(); setIndicatorAndColor(); ct = 0; adj = 2; lcd("Begin"); while (sorted<total) { canDrop(); if (visitedCount == 3) predict(); if (sorted == total) break; pickup(); traverseToSort(ct, ct % 2 + 4); sortCheck(); } for (i = 0; i<4; i++); //..printf("%d %d\n", term[i][0], term[i][1]); //..printf("Sort 0=%dSort 1=%d\nArm 0=%dArm 1=%d\n", sort[0], sort[1], arm[0], arm[1]); //..printf("Cost=%d\nSORTED!!!!!\n", cost + 7); //getch(); */ forwardJaa(); return 1; }
int main() { int i=0; init_devices(); lcd_set_4bit(); lcd_init(); color_sensor_scaling(); /* //variable 'i' scales at 13,14 for sharp sensor for velocitty 240 240 //u turn 1600ms at 200,200 velocity velocity(200,200); left(); _delay_ms(1600); stop(); while(1); threshold=6000; right(); while(ADC_Conversion(11)<65) { i++; lcd_print(1,11,i,3); } stop(); lcd_print(2,11,scan(),1); stop(); while(1); */ setIndicatorAndColor(); threshold=6000; ct = 0; adj = 2; //lcd("Begin"); while (sorted<total) { canDrop(); //buzzer_on(); //_delay_ms(500); //buzzer_off(); if (visitedCount == 3) predict(); if (sorted == total) break; pickup(); traverseToSort(ct, ct % 2 + 4); sortCheck(); } for (i = 0; i<4; i++); //..printf("%d %d\n", term[i][0], term[i][1]); //..printf("Sort 0=%dSort 1=%d\nArm 0=%dArm 1=%d\n", sort[0], sort[1], arm[0], arm[1]); //..printf("Cost=%d\nSORTED!!!!!\n", cost + 7); //getch(); return 0; }
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); } }
void color(void) // function to select red filter and display the count generated by the sensor on LCD. The count will be more if the color is red. The count will be very less if its blue or green. { color_sensor_scaling(); //Red filter_red(); //select red filter pulse=0; //reset the count to 0 _delay_ms(100); //capture the pulses for 100 ms or 0.1 second red = pulse; //store the count in variable called red //Green filter_green(); //select green filter pulse=0; //reset the count to 0 _delay_ms(100); //capture the pulses for 100 ms or 0.1 second green = pulse; //store the count in variable called green //Blue filter_blue(); //select blue filter pulse=0; //reset the count to 0 _delay_ms(100); //capture the pulses for 100 ms or 0.1 second blue = pulse; //store the count in variable called blue /*lcd_print(1,1,red,5); lcd_print(1,7,blue,5); lcd_print(1,13,green,5); */if(red<threshold && green <threshold && blue <threshold) //black color detected { data='T'; } else if(red>blue &&red >green) //red color detected { data='R'; } else //green color detected { data='G'; } }