We're sorry, but you must have Javascript enabled in your browser to access this exercise.

Avoid Walls

Define the speeds of the robot's motors depending on what it sees so it turns away from walls. Speeds are integers as in earlier exercises.

You can select a plain arena or a complex one: for the latter you can find how far the robot travels in 1000 steps.

You can also select a race track and go racing as before, but now using sensor data.

You can also select "Line to Follow", when the sensors report if they can detect the line - choose speeds so the robot follows the line.

Keyboard controls

Press D to define the speeds (use tab to move to next one). W toggles the Left Motor option; S starts/stops the robot

A C T and L set arena/track/line follow; U toggles return race, H if monitor how far moved.

I, J, K, M move the robot Up,Left, Right or Down.

Exercise Tasks

First define the speed pairs so the robot steers away from the walls it sees. Test in the plain arena and then the complex one. See how far the robot travels in 1000 steps.

Select "Track" and then Start Racing - does the robot get to the middle? If so how quickly? (You may need to rethink what to do when both sensors see a wall.)

Select a Return Race and Start Racing - you may need to rethink some speeds.

Then select 'Line to Follow' - and get the robot to follow the path.

When No Wall is seen :

When Wall detected on Left Only :

When Wall detected on Right Only :

When Wall detected on Both Sides :

Reverse Left Motor

Left motor   Right motor

Left motor   Right motor

Left motor   Right motor

Left motor   Right motor

Plain Arena Complex Arena

Track Line To Follow