[[2005/A1]]

#define freq 5 //センサ測定頻度

#define maxrot 20//一周に必要な測定回数 int l; int w; int lgt; int cnt; int turn; int back;

task main () {

	SetSensor(SENSOR_1, SENSOR_LIGHT); 	//センサ種別指定
	w=freq;
	l=0;
	for (cnt=1; cnt<=maxrot; cnt++)	
		{
		OnFwd(OUT_A); OnRev(OUT_C); Wait(w);Off(OUT_A+OUT_C);	//w/100秒間回転
		if (l <= SENSOR_1 )	//前の場所より明るかったら
			{
			l = SENSOR_1;	//明るさの最大値を更新
			lgt=cnt;
			PlaySound(SOUND_CLICK) ;
			Wait(10);
			Wait(50);
			}
		else{PlaySound(SOUND_DOUBLE_BEEP) ;
			Wait(10);
			Wait(50);
		}	
			
		}
	PlaySound(SOUND_DOUBLE_BEEP) ;
	back=maxrot;
	back=back-lgt;
	repeat(back)
		{	
		OnFwd(OUT_C); OnRev(OUT_A); Wait(w);Off(OUT_A+OUT_C);	//光源まで回転
		PlaySound(SOUND_FAST_UP) ;
			Wait(10);
			Wait(50);			
		}


トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS