We can use a touch sensor to avoid a wall. A touch sensor can be installed on the front of a car. When the sensor touches a wall, the car turn right to avoid the wall.
Example:
task main()
{
SetSensorTouch(S1);
while(1)
{
if(Sensor(S1))
{
OnFwd(OUT_A,100);
OnRev(OUT_C,100);
}
else
{
OnFwd(OUT_AC,100);
}
}
}