sub The_slide() {SetPower(OUT_C,10);OnFwd(OUT_C);Wait(10);Float(OUT_C);Wait(200);OnRev(OUT_C);Wait(60);Float(OUT_C);Wait(200); } sub Keep_slide() {;OnRev(OUT_C);Wait(30);Off(OUT_C); } sub Ride() {OnRev(OUT_A);Wait(50);Off(OUT_A);OnFwd(OUT_B);Wait(50); Off(OUT_B);OnFwd(OUT_A);Wait(60);Off(OUT_A); } sub Push() {OnFwd(OUT_A);Wait(10);OnRev(OUT_A);Wait(10);Off(OUT_A); } sub Descend() {OnFwd(OUT_B);Wait(50);Off(OUT_B);OnRev(OUT_A);Wait(200);Off(OUT_A); OnRev(OUT_B);Wait(20);Off(OUT_B); } sub Sound_Message() { PlaySound(SOUND_DOUBLE_BEEP) ;} sub Sound_Sensor() {PlaySound(SOUND_CLICK);} #define floor_distinction SENSOR_1 #define box_distinction SENSOR_2 #define Black SENSOR_2<41 #define White 52<SENSOR_2 #define Green 45<SENSOR_2<50 #define body OUT_B #define beetle OUT_A task main() {int i; SetSensor(floor_distinction, SENSOR_LIGHT); SetSensor(box_distinction, SENSOR_LIGHT); until(Message()==1); Sound_Message(); //<1>1 for(i=1;i<=20;i++){SendMessage(2);}; Wait(50); OnRev(body); until(floor_distinction<48);Sound_Sensor(); Off(body); OnRev(beetle); //2 Wait(180); Off(beetle); Wait(800); OnFwd(beetle);Wait(50);OnRev(beetle);Wait(30);OnFwd(beetle); //3 Wait(200); Off(beetle); repeat(3){OnRev(beetle);Wait(100);Off(beetle); if(Black) {Wait(20);The_slide();Keep_slide();Wait(100);} if(White) {OnFwd(body);Wait(30);until(floor_distinction<48);Sound_Sensor();Off(body); Wait(20);The_slide();Keep_slide(); OnRev(body);Wait(30);until(floor_distinction<48);Off(body);Wait(100);} if(Green) {OnFwd(body);Wait(30);until(floor_distinction<48);Sound_Sensor();Wait(30);until(floor_distinction<48);Sound_Sensor(); ;Off(body); Wait(20);The_slide();Keep_slide(); OnRev(body);Wait(30);until(floor_distinction<48);Wait(30);Sound_Sensor();until(floor_distinction<48);Sound_Sensor(); Off(body);Wait(100);} OnRev(beetle);Wait(100);Off(beetle);Wait(200);OnFwd(beetle);Wait(50);OnRev(beetle);Wait(30);OnFwd(beetle); Wait(200); Off(beetle); } OnFwd(beetle);Wait(30);until(floor_distinction<48);Off(body); until(Message()==6); Sound_Message(); //<2>1 for(i=1;i<=20;i++){SendMessage(7);}; Wait(50); OnRev(body); until(floor_distinction<48);Sound_Sensor(); Off(body); OnRev(beetle); //2 Wait(180); Off(beetle); Wait(800); OnFwd(beetle);Wait(50);OnRev(beetle);Wait(30);OnFwd(beetle); //3 Wait(200); Off(beetle); repeat(3){OnRev(beetle);Wait(100);Off(beetle); if(Black) {Wait(20);The_slide();Keep_slide();Wait(100);} if(White) {OnFwd(body);Wait(30);until(floor_distinction<48);Sound_Sensor();Off(body); Wait(20);The_slide();Keep_slide(); OnRev(body);Wait(30);until(floor_distinction<48);Off(body);Wait(100);} if(Green) {OnFwd(body);Wait(30);until(floor_distinction<48);Sound_Sensor();Wait(30);until(floor_distinction<48);Sound_Sensor(); ;Off(body); Wait(20);The_slide();Keep_slide(); OnRev(body);Wait(30);until(floor_distinction<48);Wait(30);Sound_Sensor();until(floor_distinction<48);Sound_Sensor(); Off(body);Wait(100);} OnRev(beetle);Wait(100);Off(beetle);Wait(200);OnFwd(beetle);Wait(50);OnRev(beetle);Wait(30);OnFwd(beetle); Wait(200); Off(beetle); };}