ロボティクス入門ゼミ

反転

#define THRESHOLD 48

task main () 
{
SetSensor(SENSOR_1,SENSOR_LIGHT);
SetSensor(SENSOR_2,SENSOR_TOUCH);
while(true){
if(SENSOR_1<THRESHOLD) {
Off(OUT_A);
OnFwd(OUT_C);
}
if(SENSOR_2==1){
OnFwd(OUT_A);
OnRev(OUT_C);
Wait(100);
}else{
OnFwd(OUT_A);
Off(OUT_C);
}
}
}

追い越し

#difine THRESHOLD 45 task main () {

SetSensor(SENSOR_1,SENSOR_LIGHT);
SetSensor(SENSOR_2,SENSOR_LIGHT);
SetSensor(SENSOR_3,SENSOR_TOUCH);
while(true){
if(SENSOR_1<THRESHOLD){
OnFwd(OUT_A);
Off(OUT_C);
}
if(SENSOR_2<THRESHOLD){
OnFwd(OUT_C);
Off(OUT_A);
}
if((SENSOR_1>THRESHOLD)&&(SENSOR_2>THRESHOLD)){
OnFwd(OUT_A+OUT_C);
}
if(SENSOR_3==1){
OnRev(OUT_A+OUT_C);
Wait(90);
OnFwd(OUT_A);
Off(OUT_C);
Wait(120);
OnFwd(OUT_A+OUT_C);
Wait(90);
Off(OUT_A);
OnFwd(OUT_C);
Wait(120);
OnFwd(OUT_A+OUT_C);
Wait(150);
Off(OUT_A);
OnFwd(OUT_C);
Wait(120);
OnFwd(OUT_A+OUT_C);
Wait(90);
OnFwd(OUT_A);
Off(OUT_C);
Wait(120);
OnFwd(OUT_A+OUT_C);
Wait(20);
}
}
}

曲;海は広いな♪

#define Do 523

#define Re 587

#define Mi 659

#define So 784

#define so 349

#define ra 392

task play_music() {

 while(true)
      {
          PlayTone (Mi,25);  Wait(30);
          PlayTone   (Re,25);  Wait(30);       
          PlayTone (Do,30);  Wait(30);
         
          PlayTone (ra,15);  Wait(10);
          PlayTone (Re,15);  Wait(10);
          PlayTone (Do,20);  Wait(20);
          PlayTone (ra,20);  Wait(30);
         
          PlayTone (so,15);  Wait(20);
          PlayTone (so,15);  Wait(20);
          PlayTone (Do,20);  Wait(20);
          PlayTone (Do,20);  Wait(20);
          PlayTone (Re,30);  Wait(40);
          
          PlayTone (Mi,25);  Wait(20);
          PlayTone (Mi,25);  Wait(20);
          PlayTone (So,30);  Wait(30);
         
          PlayTone (Mi,15);  Wait(20);
          PlayTone (Mi,15);  Wait(20);
          PlayTone (Re,20);  Wait(20);
          PlayTone (Do,30);  Wait(30);
          
          PlayTone (ra,15);  Wait(20);
          PlayTone (ra,15);  Wait(20);
          PlayTone (so,20);  Wait(20);
          PlayTone (Re,30);  Wait(20);
          PlayTone (Do,40);  Wait(40);
          
          
          }
        }

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2006-08-09 (水) 14:06:59