ロボティクス入門ゼミ

はじめてのプログラム

task main() {

   OnFwd(OUT_A+OUT_C);
   Wait(500);
   OnFwd(OUT_A);OnRev(OUT_C);
   Wait(150);
   OnFwd(OUT_A+OUT_C);
   Wait(300);
   Off(OUT_A+OUT_C);

}

四角形を書いてみよう

 task main()

{
 OnFwd(OUT_A+C)
 Wait(300);
 OnFwd(OUT_A)
 Wait(135)

タッチセンサーを使おう

  task main() {

  SetSensor(SENSOR_1,SENSOR_TOUCH);
  SetSensor(SENSOR_2,SENSOR_TOUCH);
  
  while(true)
  {
     OnFwd(OUT_A+OUT_C);
     
     if(SENSOR_1==1)
     {
     OnRev(OUT_C);
     Wait(150);
     }
     if(SENSOR_2==1)
     {
     OnRev(OUT_A);
     Wait(100);
     }
    }
    }

追い抜きロボット

 #define THRESHOLD 40 // 閾値

task main () {

   SetSensor(SENSOR_1, SENSOR_LIGHT);
   while (true) {
       if (SENSOR_1 < THRESHOLD) {   // 黒線上にいるとき
           OnFwd(OUT_A);
           Off (OUT_C);
       } else {                      // 黒線から外れたとき
           Off(OUT_A);
           OnFwd(OUT_C);
       }
        if (SENSOR_3  ==1 )
        {
           OnFwd(OUT_A);
           OnRev(OUT_C);
           Wait(50);
           OnFwd(OUT_A+OUT_C);
           Wait(100);
           OnFwd(OUT_C);
           OnRev(OUT_A);
           Wait(85);
           OnFwd(OUT_A+OUT_C);
           Wait(170);
          }
       
   }

}

メモ

#define Do 523

#define Re 587

#define Mi 659

#define Fa 698

#define Sol 784

#define Ra 880

#define Si 988

#define Doa 1047

#define Rea 1175

#define Mia 1319

#define Faa 1397 task play_music() {

   while (true)
   {
       PlayTone(Mi,35); Wait(40);
       PlayTone(Sol, 35); Wait(40);
       PlayTone(Doa,35); Wait(40);
       PlayTone(Doa,75); Wait(80);
       PlayTone(Doa,115); Wait(120);
       PlayTone(Mi,35); Wait(40);
       PlayTone(Sol, 35); Wait(40);
       PlayTone(Doa,35); Wait(40);
       PlayTone(Doa,75); Wait(80);
       PlayTone(Doa,115); Wait(120);
       PlayTone(Fa,35); Wait(40);
       PlayTone(Ra, 35); Wait(40);
       PlayTone(Doa,35); Wait(40);
       PlayTone(Doa,75); Wait(80);
       PlayTone(Doa,115); Wait(120);
       PlayTone(Si,35); Wait(40);
       PlayTone(Ra,35); Wait(40);
       PlayTone(Si,35); Wait(40);
       PlayTone(Si,195); Wait(200);
       PlayTone(Sol,35); Wait(40);
       PlayTone(Sol,35); Wait(40);
       PlayTone(Ra,235); Wait(560);
       PlayTone(Sol,35); Wait(40);
       PlayTone(Sol,35); Wait(40);
       PlayTone(Ra, 235); Wait(560);
       PlayTone(Mi,35); Wait(40);
       PlayTone(Mi,35); Wait(40);
       PlayTone(Sol,35); Wait(40);
       PlayTone(Sol,35); Wait(40);
       PlayTone(Sol,35); Wait(40);
       PlayTone(Sol,75); Wait(80);
       PlayTone(Mi,75); Wait(80);
       PlayTone(Doa,35 ); Wait(40);
       PlayTone(Ra,235); Wait(240);
       PlayTone(Mi,35); Wait(40);
       PlayTone(Fa,35); Wait(40);
       PlayTone(Sol,35); Wait(40);
       PlayTone(Sol,115); Wait(120);
       PlayTone(So,35); Wait(40);
       PlayTone(Mi,75); Wait(80);
       PlayTone(Doa,35); Wait(40);
       PlayTone(Ra,155); Wait(240);
       PlayTone(Ra,35); Wait(40);
       PlayTone(Ra,35); Wait(40);
       PlayTone(Si,35); Wait(40);
       PlayTone(Si,195); Wait(200);
       PlayTone(Si,35); Wait(40);
       PlayTone(Si,35); Wait(40);
       PlayTone(Doa,155); Wait(240);
       PlayTone(Doa,35); Wait(40);
       PlayTone(Doa,35); Wait(40);
       PlayTone(Rea,75); Wait(80);
       PlayTone(Rea,35); Wait(40);
       PlayTone(Rea,35); Wait(40);
       PlayTone(Rea,75); Wait(80);
       PlayTone(Faa,35); Wait(40);
       PlayTone(Mia,75); Wait(80);
       PlayTone(Rea,155); Wait(240);
       PlayTone(Sol,35); Wait(40);
       PlayTone(Sol,35); Wait(40);
       PlayTone(Mia,35); Wait(40);
       PlayTone(Mia,195); Wait(200);
       PlayTone(Rea,35); Wait(40);
       PlayTone(Doa35,); Wait(40);
       PlayTone(Si,35); Wait(40);
       PlayTone(Si,195); Wait(200);
       PlayTone(Si,35); Wait(40);
       PlayTone(Si,35); Wait(40);
       PlayTone(Ra,35); Wait(40);
       PlayTone(Ra,195); Wait(200);
       PlayTone(Doa,35); Wait(40);
       PlayTone(Ra,35); Wait(40);
       PlayTone(Ra,115); Wait(120);
       PlayTone(Sol,115); Wait(120);
       PlayTone(Sol,35); Wait(40);
       PlayTone(Sol,35); Wait(40);
       PlayTone(Ra,195); Wait(200);
       PlayTone(Doa,75); Wait(80);
       PlayTone(Ra,35); Wait(40);
       PlayTone(Mia,75); Wait(160);
       PlayTone(Rea,35); Wait(40);
       PlayTone(Doa,75); Wait(80);
       PlayTone(Si,35); Wait(40);
       PlayTone(Doa,235); Wait(240);
       PlayTone(Rea,35); Wait(40);
       PlayTone(Doa,35); Wait(40);
       PlayTone(Doa,35); Wait(40);
       PlayTone(Doa,75); Wait(120);
       Wait(20);
   }

}

task main() { start play_music }


トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2006-07-05 (水) 17:05:38 (4794d)