We can avoid the wall with touch sensor or ultrasonic sensor. We can install a ultrasonic sensor on the front of a car. When the sensor senses a wall, the car turns right to avoid the wall.
Example:
task main()
{
SetSensorUltrasonic(S1);
while(1)
{
if(SensorUS(S1) < 20)
{
OnFwd(OUT_A,100);
OnFwd(OUT_C,-100);
}
else
{
OnFwd(OUT_AC,100);
}
}
}