この2台をもとに新しいロボットを作りだした。 ただし、ただ付け加えるだけでは、速さが不十分であると感じたので、タイヤを変更し、ベース部分も無駄な部分は取り払った。
プログラム自体はそんなに長くはならないが、基本的な動きに充実であるように組んだ。 しかし、交差点の時の為の細かい調整は必要だった。
#define THRESHOLD 42 #define RUN_TIME 150 #define GOGO OUT_A+OUT_C // define a gogo as onfwd task main () { SetSensor(SENSOR_1, SENSOR_LIGHT); SetSensor(SENSOR_2, SENSOR_TOUCH); SetSensor(SENSOR_3, SENSOR_LIGHT); // define a sensor as light n touch OnFwd(GOGO); while(true){ if((SENSOR_1 >= THRESHOLD) && (SENSOR_3 >= THRESHOLD)){ OnFwd(GOGO); // when they find themself in white ground go ahead }else if((SENSOR_1 < THRESHOLD) && (SENSOR_3 >= THRESHOLD)){ OnFwd(OUT_C); OnRev(OUT_A); // when they find themself in black line on their right go right }else if((SENSOR_1 >= THRESHOLD) && (SENSOR_3 < THRESHOLD)){ OnFwd(OUT_A); OnFwd(OUT_C); // when the find themself in black line on their left go left }else if((SENSOR_1 < THRESHOLD) && (SENSOR_3 < THRESHOLD)){ OnFwd(GOGO); // when they find themself in black line on both go ahead } if(SENSOR_2 == 1) { OnRev(OUT_A+OUT_C); Wait(200); Off(OUT_C); OnFwd(OUT_A); Wait(250); Off(OUT_A); OnFwd(OUT_C); // when they was touched by somthing, wait a sec and turn right and go straight Wait(250); } } } //if(SENSOR_2 == 1) { Off(OUT_A+OUT_C); Wait(100); OnFwd(OUT_C); OnRev(OUT_A); Wait(180); Fwd(OUT_A); // in a case we can use this source on the end of the program
些細なことでも、何かお気付きになられましたら、コメントの方お願いしますm(_ _)m