Code: Select all
task main (){
#define NEAR 15 // cm
SetSensorLowspeed(IN_1);
while(true){
OnFwd(OUT_AC,75);
while(SensorUS(IN_1)>NEAR);
Off(OUT_AC);
OnRev(OUT_AC,100);
}
#define THRESHOLD 29
SetSensorLight(IN_2);
OnFwd(OUT_AC,75);
while(true){
if (Sensor(IN_2) > THRESHOLD){
OnRev(OUT_C, 75);
Wait(100);
until(Sensor(IN_2) <= THRESHOLD);
OnFwd(OUT_AC, 75);
}
#define THRESHOLD 29
SetSensorLight(IN_3);
OnFwd(OUT_AC,75);
while(true){
if (Sensor(IN_2) > THRESHOLD){
OnRev(OUT_C, 75);
Wait(100);
until(Sensor(IN_3) <= THRESHOLD);
OnFwd(OUT_AC, 75);
}
}
}
}