2005/C5/最も明るいところを見つけるプログラム
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
[[2005/C5/けんいち]]
int light_max=0;
int RUN_TIME=480;
int MAX_TIMER=0;
task main(){
SetSensor(SENSOR_1,SENSOR_LIGHT);
ClearTimer(0);
while(FastTimer(0)<=RUN_TIME)
{
OnFwd(OUT_A);OnRev(OUT_C);
if(SENSOR_1>light_max)
{
light_max=SENSOR_1;PlayTone(500,5);
MAX_TIMER=FastTimer(0);
}
}
ClearTimer(0);
while(FastTimer(0)<=MAX_TIMER)
OnRev(OUT_C);OnFwd(OUT_A);
Off(OUT_A+OUT_C);
}
終了行:
[[2005/C5/けんいち]]
int light_max=0;
int RUN_TIME=480;
int MAX_TIMER=0;
task main(){
SetSensor(SENSOR_1,SENSOR_LIGHT);
ClearTimer(0);
while(FastTimer(0)<=RUN_TIME)
{
OnFwd(OUT_A);OnRev(OUT_C);
if(SENSOR_1>light_max)
{
light_max=SENSOR_1;PlayTone(500,5);
MAX_TIMER=FastTimer(0);
}
}
ClearTimer(0);
while(FastTimer(0)<=MAX_TIMER)
OnRev(OUT_C);OnFwd(OUT_A);
Off(OUT_A+OUT_C);
}
ページ名: