#contents *今回の課題 [#d8f15565] [[2017b/Member]] #define up(t) OnRev(OUT_A);Wait(t);Off(OUT_AC); #define down(t) OnFwd(OUT_A);Wait(t);Off(OUT_AC); #define st(t) Off(OUT_AC);Wait(t); task main () {Wait(870); up(30); st(200); down(30); } #define leftSENKAI OnFwd(OUT_A);OnRev(OUT_C); //左旋回 #define leftMAGARU OnFwd(OUT_A);Off(OUT_C); //左折 #define rightSENKAI OnFwd(OUT_C);OnRev(OUT_A); //右旋回 #define rightMAGARU OnFwd(OUT_C);Off(OUT_A); //右折 #define ch OnFwd(OUT_B);Wait(30);Off(OUT_B); //アームを閉じる #define re OnRev(OUT_B);Wait(20);Off(OUT_B); //アームを開く #define go(t) OnFwd(OUT_AC);Wait(t);Off(OUT_AC); //t秒前進 #define back(t) OnRev(OUT_AC);Wait(t);Off(OUT_AC); //t秒後退 #define cross_stop Off(OUT_AC);Wait(100); //1秒止まる #define carb 46 //閾値 sub r() { SetSensor(SENSOR_2,SENSOR_LIGHT); ClearTimer(0); while(FastTimer(0)<=24) { if(SENSOR_2>carb+5) { leftSENKAI ClearTimer(0); } else if(SENSOR_2>carb+3) { leftMAGARU ClearTimer(0); } else if(SENSOR_2>carb) { OnFwd(OUT_AC); ClearTimer(0); } else if(SENSOR_2>carb-3) { rightMAGARU ClearTimer(0); } else { rightSENKAI } } Off(OUT_AC); } task main () {go(30); r(); leftSENKAI; Wait(5); re; go(160); cross_stop; ch; rightSENKAI; Wait(140); cross_stop; ch; go(90); cross_stop; re; back(100); leftSENKAI; Wait(30); go(200); rightSENKAI; Wait(40); re; go(250); }