

#pragma config(Sensor, S4,     left,           sensorEV3_Ultrasonic)
#pragma config(Sensor, S3,     right,          sensorEV3_Ultrasonic)
//*!!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 EV3 Screen
void display_values() {
				displayBigTextLine(0, "Left: %d %d%%", left_count, (left_count*100)/total_count);
			displayBigTextLine(2, "Right: %d %d%%", right_count, (right_count*100)/total_count);
			displayBigTextLine(4, "Total: %d ", total_count);
}

task main()
{
	while(true) {
		if(getUSDistance(left)<10) {   	//If a ball is spotted rolling out of the left foot
			left_count++;									//Increment left foot variable
			total_count++;								//Increment total count
      waitUntil(getUSDistance(left)>12);  //Wait for the ball to roll away
			display_values();										//Show results on the EV3 Display
		}
		if(getUSDistance(right)<10) {
			right_count++;
			total_count++;
			waitUntil(getUSDistance(right)>12);
			display_values();
		}
	}
}
