2005/A3

壁に沿うロボット program editer Hideshi

基本プログラム

sub Go(){OnFwd(OUT_A+OUT_C);}
sub Back(){OnRev(OUT_A+OUT_C);Wait(19);Off (OUT_A+OUT_C);}
sub Left_Turn(){OnRev(OUT_A);OnFwd(OUT_C);Wait(60);}
sub Right_Turn(){OnRev(OUT_C);OnFwd(OUT_A);Wait(60);}

実際に動かす(機体の前と右にセンサーを設置)

task main()
{SetSensor(SENSOR_2,SENSOR_TOUCH);      //front sensor
SetSensor(SENSOR_3,SENSOR_TOUCH);                    //right sensor
while(true)
{Go();
if(SENSOR_2==1){Back();Left_Turn();Go();Off(OUT_C);Wait(30);Go();Wait(80);};  
                                                         //If sensor of only front turn on,the machine turn left.
if(SENSOR_3!=1){Wait(80);Right_Turn();Go();Wait(50);Off(OUT_C);Wait(10);Go();Wait(80);};}
                                                        //if sensor of only right turn off,the machine turn right
}

工夫点

コメントをお願いします



添付ファイル: file1 165件 [詳細]

トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2007-01-22 (月) 12:11:34