- 履歴一覧
- ソース を表示
- 2005/A5/学習ノート Hypodytes rubripinnis/光を追いかけるロボット2 は削除されています。
- 1 (2005-12-12 (月) 09:28:52)
- 追加された行はこの色です。
- 削除された行はこの色です。
#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});
}
}
}