[[2006b/A1/課題3左]]

*センサー2個のプログラム [#l43e1c04]

 #define TURN_TIME 400
 #define left OnRev(OUT_A);OnFwd(OUT_C);
 #define go OnFwd(OUT_A+OUT_C);
 #define offAC Off(OUT_A+OUT_C);
 #define TURN_LIGHT 10
 #define turn_go 5
 task main()
 {
 
 int light_max=0,time_max=0;
 SetSensor(SENSOR_1,SENSOR_LIGHT);
 SetSensor(SENSOR_2,SENSOR_LIGHT);
 
 start play_music;
 
 ClearTimer(0);OnFwd(OUT_A);OnRev(OUT_C);
 
 while(FastTimer(0)<TURN_TIME){
       
       if(SENSOR_1>light_max)
       {
       light_max=SENSOR_1;
       time_max=FastTimer(0);
       }
       }
       OnRev(OUT_A);OnFwd(OUT_C);
       Wait(TURN_TIME-time_max);
        Off(OUT_A+OUT_C);
        
 stop play_music;    
       
         
 while(true){
      if(SENSOR_1>SENSOR_2)
      {
      OnFwd(OUT_C);
      OnRev(OUT_A);
      Wait(TURN_LIGHT);
      OnFwd(OUT_A+OUT_C);Wait(turn_go);
      }
      if(SENSOR_1<SENSOR_2)
      {
      OnFwd(OUT_A);
      OnRev(OUT_C);
      Wait(TURN_LIGHT);
      OnFwd(OUT_A+OUT_C);Wait(turn_go);
      }
     
       
            }
            }
            
            
              
             
 
 #define Do 523
 #define Re 587 
 #define Mi 659 
 #define Fa 698 
 #define Sol 784 
 #define ma 55 
 #define k 50
            
 task play_music()
 { 
 while(true)
 {
 曲
 
 }
 }

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