*ハードウェア [#g7f6889d]

*ソフトウェア [#t11159cd]
 task main(){
 SetSensor(SENSOR_2,SENSOR_LIGHT);
 SetSensor(SENSOR_1,SENSOR_TOUCH);
 int i = 0;
 int j = 0;
 int T = 0;
 ClearTimer(1);
 while(1){
 	if(SENSOR_1 == 1){
			i++;
			ClearTimer(0);
		}
		if(i == 1){
			OnFwd(OUT_B);
			Wait(50);
			Off(OUT_B);
			i++;
			ClearTimer(0);
		}
  if(SENSOR_2 > 50 && SENSOR_2 <55){
   OnRev(OUT_A);
   Off(OUT_C);
   ClearTimer(0);
   }if(SENSOR_2 >56){
   	int t = FastTimer(0);
   	int T = FastTimer(1);
   	if((T > 1000 && T < 1800) || (T > 2500 && T <3300)){
	   	if(t >20){
   			PlaySound(SOUND_UP);
   			Off(OUT_AC);
   			Wait(200);
  			ClearTimer(0);
  	   	}else{
   			OnRev(OUT_A);
   			OnFwd(OUT_C);
   		}
   	}
   	if(T > 3700){
   		if(t > 20){
   			PlaySound(SOUND_UP);
   			Off(OUT_AC);
   			OnFwd(OUT_B);
			Wait(50);
			Off(OUT_B);
   			OnRev(OUT_AC);
   			Wait(100);
   			Off(OUT_AC);
   			Wait(1000);
   			ClearTimer(0);
   		}else{
   			OnRev(OUT_A);
   			OnFwd(OUT_C);
   		}
   	}else{
   		OnRev(OUT_A);
		OnFwd(OUT_C);
   	}
   }   
   else if(SENSOR_2 < 49 && SENSOR_2 >45){
   	OnFwd(OUT_A);
   	OnRev(OUT_C);
   	ClearTimer(0);
   }
   else if(SENSOR_2 < 40){
   	OnRev(OUT_AC);
   	ClearTimer(0);
   }	
   else{
   OnRev(OUT_C);
   Off(OUT_A);
   ClearTimer(0);
  }
 }
}


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