int Colour[5]; int ColourCnt; task main() { SetSensor (SENSOR_1, SENSOR_ROTATION); SetSensor (SENSOR_2, SENSOR_LIGHT); SetSensor (SENSOR_3, SENSOR_TOUCH); int Bucket; Colour[1] = 0; Colour[2] = 0; Colour[3] = 0; ColourCnt = 0; Bucket = 0; Eject (); repeat (8) //repeats 8 times till chute is empty { ReturnSorter (); Inject(); Wait (50); Calibrate (Bucket); PlaySound (SOUND_DOUBLE_BEEP); Rotate(Bucket); PlaySound (SOUND_FAST_UP); Eject (); PlaySound (SOUND_CLICK); ReturnSorter (); } SleepNow (); // turns RCX off at end of program } sub Inject () //injects the bricks into the sorter { if (SENSOR_3 == 1) { OnRev (OUT_C); OnFor (OUT_C, 120); OnFwd (OUT_C); OnFor (OUT_C, 100); } Off (OUT_C); } void Calibrate (int &Bucket) /* calibrates the first 3 bricks and uses their colour to determine if it is a knowen or unknowen block colour */ { int x; int BlkClr; int Blim; int Tlim; BlkClr = SENSOR_2; //Read colour of block Bucket = 4; x=0; for (x=1; x