#define go OnFwd(OUT_A+OUT_C); //Á°¿Ê #define back OnRev(OUT_A+OUT_C); //¸åÂà #define tomaru Off(OUT_A+OUT_C); //Ää»ß #define turn_l OnFwd(OUT_A); //º¸ÀÞ #define turn_r OnFwd(OUT_C); //±¦ÀÞ #define shine 45 //¥é¥¤¥ó¥È¥ì¡¼¥¹¤Î¤¿¤á¤Î¸÷¤ÎÃÍ #define up(t) OnFwd(OUT_B);Wait(t);Off(OUT_B); //¥¢¡¼¥à¤ò¾å¤²¤ë #define down(t) OnRev(OUT_B);Wait(t);Off(OUT_B);//¥¢¡¼¥à¤ò²¼¤²¤ë task follow_line_1(){ //¸òº¹ÅÀ¤òľ¿Ê¤¹¤ë¥×¥í¥°¥é¥à while(true){ if((SENSOR_3 >= shine)&&(SENSOR_1 >= shine)){ go; until((SENSOR_3 < shine)||(SENSOR_1 < shine)); tomaru; } else if((SENSOR_3 < shine)&&(SENSOR_1 >= shine)){ turn_l; until((SENSOR_3 >= shine)&&(SENSOR_1 >= shine)); tomaru; } else if((SENSOR_3 >= shine)&&(SENSOR_1 < shine)){ turn_r; until(((SENSOR_3 >= shine)&&(SENSOR_1 >= shine))||((SENSOR_3 < shine)&&(SENSOR_1 < shine))); tomaru; } else if((SENSOR_3 < shine)&&(SENSOR_1 < shine)){ PlaySound(SOUND_UP); turn_l; until((SENSOR_3 >= shine)&&(SENSOR_1 >= shine)); tomaru; } } } task follow_line_2(){ //¸òº¹ÅÀ¤ò±¦ÀÞ¤¹¤ë¥×¥í¥°¥é¥à¡²¾ì¹ç1 while(true){ if((SENSOR_1 >= shine)&&(SENSOR_3 >= shine)){ go; until((SENSOR_1 < shine)||(SENSOR_3 < shine)); tomaru; } else if((SENSOR_1 < shine)&&(SENSOR_3 >= shine)){ turn_r; until(((SENSOR_1 >= shine)&&(SENSOR_3 >= shine))||((SENSOR_1 < shine)&&(SENSOR_3 < shine))); tomaru; } else if((SENSOR_1 >= shine)&&(SENSOR_3 < shine)){ turn_l; until(((SENSOR_1 >= shine)&&(SENSOR_3 >= shine))||((SENSOR_1 < shine)&&(SENSOR_3 < shine))); tomaru; } else if((SENSOR_1 < shine)&&(SENSOR_3 < shine)){ PlaySound(SOUND_UP); OnFwd(OUT_C);OnRev(OUT_A); until((SENSOR_1 >= shine)&&(SENSOR_3 >= shine)); tomaru; } } } task follow_line_3(){ //¸òº¹ÅÀ¤ò±¦ÀÞ¤¹¤ë¥×¥í¥°¥é¥à¡²¾ì¹ç2 PlaySound(1); while(true){ if((SENSOR_1 >= shine)&&(SENSOR_3 >= shine)){ go; until((SENSOR_1 < shine)||(SENSOR_3 < shine)); tomaru; } else if((SENSOR_1 < shine)&&(SENSOR_3 >= shine)){ turn_r; until(((SENSOR_1 >= shine)&&(SENSOR_3 >= shine))||((SENSOR_1 < shine)&&(SENSOR_3 < shine))); tomaru; } else if((SENSOR_1 >= shine)&&(SENSOR_3 < shine)){ turn_l; until((SENSOR_1 >= shine)&&(SENSOR_3 >= shine)); tomaru; } else if((SENSOR_1 < shine)&&(SENSOR_3 < shine)){ PlaySound(SOUND_UP); OnFwd(OUT_C);OnRev(OUT_A); ClearTimer(0); //¸òº¹ÅÀ¤ò¶Ê¤¬¤ë¤È¤¶Ê¤¬¤ê¤¹¤®¤Ê¤¤¤è¤¦¤Ë¶Ê¤¬¤ë»þ´Ö¤ÎºÇÂç¤ò·è¤á¤ë until(((SENSOR_1 >= shine)&&(SENSOR_3 >= shine))||(FastTimer(0) > 70)); tomaru; } } } task follow_line_4(){ //¸òº¹ÅÀ¤òº¸ÀÞ¤¹¤ë¥×¥í¥°¥é¥à int k=0; while(true){ if((SENSOR_1 >= shine)&&(SENSOR_3 >= shine)){ go; until((SENSOR_1 < shine)||(SENSOR_3 < shine)); tomaru; } else if((SENSOR_1 < shine)&&(SENSOR_3 >= shine)){ turn_r; until(((SENSOR_1 >= shine)&&(SENSOR_3 >= shine)||((SENSOR_1 < shine)&&(SENSOR_3 < shine))); tomaru; } else if((SENSOR_1 >= shine)&&(SENSOR_3 < shine)){ turn_l; until(((SENSOR_1 >= shine)&&(SENSOR_3 >= shine))||((SENSOR_1 < shine)&&(SENSOR_3 < shine))); tomaru; } else if(((SENSOR_1 < shine)&&(SENSOR_3 < shine))&&(k<1)){ PlaySound(SOUND_UP);k++; //¸òº¹ÅÀ¤Î²ó¿ô¤ò¿ô¤¨¤ë OnFwd(OUT_A);OnRev(OUT_C); until((SENSOR_1 >= shine)&&(SENSOR_3 >= shine)); tomaru; } else if(((SENSOR_1 < shine)&&(SENSOR_3 < shine))&&(k==1)){ tomaru; //²¼¿Þ¤Î¸òº¹ÅÀ£±¤ò°ì²ó¶Ê¤¬¤Ã¤Æ¥¹¥¿¡¼¥ÈÃÏÅÀ¤Þ¤ÇÍ褿¤é»ß¤Þ¤ë } } } task follow_line_5(){ //¶¹¤¤ÄÌÏ©¤òÄ̤뤿¤á¤Î¥×¥í¥°¥é¥à while(true){ if(SENSOR_1 >= shine){ turn_l; until(SENSOR_1 < shine); tomaru; } else if(SENSOR_1 < shine){ turn_r; until(SENSOR_1 >= shine); tomaru; } } } task main(){ SetSensor(SENSOR_1,SENSOR_LIGHT);//¥»¥ó¥µ¡¼1¤ò¸÷¥»¥ó¥µ¡¼¤Ë·è¤á¤ë SetSensor(SENSOR_2,SENSOR_TOUCH);//¥»¥ó¥µ¡¼2¤ò¥¿¥Ã¥Á¥»¥ó¥µ¡¼¤Ë·è¤á¤ë SetSensor(SENSOR_3,SENSOR_LIGHT);//¥»¥ó¥µ¡¼3¤ò¸÷¥»¥ó¥µ¡¼¤Ë·è¤á¤ë start follow_line_1; //¥¹¥¿¡¼¥ÈÃÏÅÀ¤«¤é»æ¥Ñ¥Ã¥¯¤Î²£¤Þ¤Ç¿Ê¤à Wait(460); stop follow_line_1; tomaru; OnFwd(OUT_C);OnRev(OUT_A); //»æ¥Ñ¥Ã¥¯¤ò¤È¤ë¤¿¤á¤Ë±¦¤Ë90ÅÙÊý¸þÊÑ´¹ Wait(100); tomaru; go; //»æ¥Ñ¥Ã¥¯¤ËÅö¤¿¤ë¤Þ¤Ç¿Ê¤à until(SENSOR_2 == 1); tomaru; down(70); //»æ¥Ñ¥Ã¥¯¤ò¤Ä¤«¤à go; Wait(20); tomaru; down(70); back; //¥é¥¤¥ó¾å¤ËÌá¤ë¤Þ¤Ç¥Ð¥Ã¥¯ until((SENSOR_1 < shine)&&(SENSOR_3 < shine)); tomaru; OnFwd(OUT_A);OnRev(OUT_C); Wait(60); tomaru; start follow_line_1; //¥é¥¤¥ó¥È¥ì¡¼¥¹¤ò³«»Ï Wait(500); stop follow_line_1; tomaru; up(200); go; //»æ¥Ñ¥Ã¥¯¤ò¼ÙËâ¤Ë¤Ê¤é¤Ê¤¤¤È¤³¤í¤ØÃÖ¤¤¤Æ¤¯¤ë Wait(200); //¡Ê²¼¿Þ¤Î»æ¥Ñ¥Ã¥¯¤È½ñ¤«¤ì¤Æ¤¤¤ë¤È¤³¤í¤ØÃÖ¤¤¤Æ¤¤¤¯¡Ë tomaru; back; Wait(235); tomaru; OnFwd(OUT_C);OnRev(OUT_A); Wait(110); tomaru; go; Wait(50); tomaru; start follow_line_5; //°ì¼þ²ó¤Ã¤Æ¥¹¥¿¡¼¥ÈÃÏÅÀ¤ØÌá¤ë Wait(300); stop follow_line_5; tomaru; start follow_line_2; //²¼¿Þ¤Î¸òº¹ÅÀ£³¤òÄ̲᤹¤ë Wait(900); stop follow_line_2; tomaru; start follow_line_3; //²¼¿Þ¤Î¸òº¹ÅÀ£´¤òÄ̲᤹¤ë Wait(800); stop follow_line_3; tomaru; start follow_line_4; //²¼¿Þ¤Î¸òº¹ÅÀ£±¤òÄ̲᤹¤ë Wait(600); stop follow_line_4; tomaru; OnFwd(OUT_A); //¤â¤¦°ìÂæÆþ¤ì¤ë¤è¤¦¤ËåºÎï¤Ë¥¹¥¿¡¼¥ÈÃÏÅÀ¤ËÆþ¤ë Wait(15); tomaru; go;until(SENSOR_2 == 1);tomaru; back;Wait(55);tomaru; OnFwd(OUT_A);OnRev(OUT_C); Wait(90); tomaru; go; until((SENSOR_1 < shine)&&(SENSOR_3 < shine)); tomaru; }
¥í¥Ü¥Ã¥È¤Î¿Ê¤à·ÐÏ©