task main () { int OldClock; int AmbLevelThr1; int AmbLevelThr2; int i; SetSensorType (SENSOR_1, SENSOR_TYPE_LIGHT); SetSensorMode (SENSOR_1, SENSOR_MODE_RAW); SetSensorType (SENSOR_2, SENSOR_TYPE_LIGHT); SetSensorMode (SENSOR_2, SENSOR_MODE_RAW); Wait(10); // Wait for active sensors initialisation while (true) { AmbLevelThr1 = SENSOR_1 - 8; AmbLevelThr2 = SENSOR_2 - 8; OnFwd (OUT_A); // Start elevator ClearTimer (1); // Wait for ball until ((SENSOR_1 < AmbLevelThr1)||(SENSOR_2 < AmbLevelThr2)) { if(Timer(1)>600) { Off (OUT_A); //No ball detected for 1min, Stop all!) PlaySound (SOUND_DOWN); StopAllTasks (); } } Off (OUT_A); // We got a ball OldClock = Watch(); while(OldClock == Watch()); // Wait for the next minute. if(Watch()%60 == 0) // Each hour, wait to compensate for fast clock! { Wait(692); // My RCX is fast by 6.92 seconds each hour SetWatch(0,0); } } }