

#pragma config(Sensor, port1,  left,           sensorVexIQ_Color12Color)
#pragma config(Sensor, port2,  right,          sensorVexIQ_Color12Color)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

//Initialise Variables
int left_count = 0;
int right_count = 0;
int total_count = 0;

//Calculate and Display percentages on the VEX IQ Screen
void display_values() {
		displayTextLine(0, "Left:  %d %d%%", left_count, (left_count*100)/total_count);
		displayTextLine(1, "Right: %d %d%%", right_count, (right_count*100)/total_count);
		displayTextLine(2, "Total: %d ", total_count);
}

task main()
{
	while(true) {
		if(getColorProximity(left)>200) {  	//If a ball rolls in front of the sensor
			left_count++;                 		//Increment relevant variable
			total_count++;										//Increment total count
      waitUntil(getColorProximity(left)<190);  	//Wait for the ball to roll away
			display_values();													//Display Values on VEX IQ Screen
		}
		if(getColorProximity(right)>200) {
			right_count++;
			total_count++;
			waitUntil(getColorProximity(right)<190);
			display_values();
		}
	}
}
