task main()
{
	short A = 0;
	long  nLoopCount;

	const tSensors rotation = S2;
	const tSensors light 		= S3;
	const tSensors sonar 		= S4;

	const int kLoopTime  = 60000;  // One minute

	SensorType[rotation] = sensorRotation;
	SensorType[light]    = sensorLightActive;
	SensorType[sonar]    = sensorSONAR9V;
	bFloatDuringInactiveMotorPWM = true;

	time1[T1] = 0;
	for (nLoopCount = 0; time1[T1] < kLoopTime; ++nLoopCount)
	{
		short nRandom;
		long  lDisplay;
		short nSensorSum;

		//nxtDisplayStringAt(12, 31, "%4d", SensorValue[light]);

		nRandom = random(100);

		nSensorSum = (SensorValue[rotation] + SensorValue[light] + SensorValue[sonar]);
		lDisplay   = nSensorSum;
		lDisplay  *= 100;
		lDisplay  /= nRandom;
		//nxtDisplayStringAt(0, 15, "%6d", lDisplay);

		motor[motorB] = nRandom;
		motor[motorC] = nRandom;

		if (nRandom > 50)
			++A;
		else if (nRandom < 50)
			--A;

		//nxtDisplayStringAt(12, 23, "%4d", A);

		motor[motorA] = A;

		//nxtDisplayStringAt(6,  7, "%5d", nLoopCount);
	}
	wait1Msec(10000);
	return;
}
