***[[学習ノート Hypodytes rubripinnis>2005/A5/学習ノート Hypodytes rubripinnis]] [#ja9017cd] ***課題3:光を追いかけるプログラム[[課題4右>2005/A5/課題4右]] [#bf0b18eb] *&color(red){現在製作中!しばしお待ちを!!}; [#a0482bd1] *光を追いかけるプログラム『センサー2個ver.』 &size(30){&color(red){'''movie'''''↓''};}; [#w0f52751] 作成者:Hypodytes rubripinnis 最終更新日:12/12 #define go_straight OnFwd(OUT_A+OUT_C); #define turn_right OnFwd(OUT_A);OnRev(OUT_C); #define turn_left OnFwd(OUT_C);OnRev(OUT_A); #define minous 15 int max; int time; task main() { SetSensor(SENSOR_1,SENSOR_LIGHT); SetSensor(SENSOR_3,SENSOR_LIGHT); max=SENSOR_1; time=Timer(0); ClearTimer(0); while(Timer(0)<=14) { turn_right if(SENSOR_1>max) { ClearTimer(1); max=SENSOR_1; } else { max=max; time=Timer(1); } } ClearTimer(1); while(Timer(1)<=time) {turn_left} while(true) { if((SENSOR_1>=max-minous)==(SENSOR_3>=max-minous)) {go_straight} if(SENSOR_1>(SENSOR_3<=max-minous)) { turn_right until({SENSOR_1>=max-minous}=={SENSOR_3>=max-minous}); } if((SENSOR_1<=max-minous)>SENSOR_3) { turn_left until({SENSOR_1>=max-minous}=={SENSOR_3>=max-minous}); } } } ''仕組み&工夫したところ'' #comment