Handling the Silver Edge...

Suppose our Robot was in the position shown below. If we want our Robot to follow the silver edge of the Robot Racing Arena, we would want the Robot to turn to the left (anti-clockwise), as shown in the image below.

Turn off silver 

To teach the Robot to turn left, we could stop the left motor (Motor A) and teach the right motor (Motor C) to go forwards. This would have the effect of both moving the Robot forwards, and swinging it to the left at the same time. This would also cause the light sensor to move off the silver area of the arena, on to the black portion of the arena.

NXT-G Commands for Turning Left.

The NXT-G commands to teach our Robot to do this could be:-

Where the command panel for motor A is:-

and the command panel for motor C is:-

We have placed the light sensor on the back of Robot2, so now the direction "backwards" in the command panel will actually be "forwards" for our Robot.

Note that the speed has been cut down to 50; this is to allow us to more easily see how the Robot is behaving.

Turning Left for Ever?

The commands above would turn our Robot to the left for ever - but we only want it to turn left when the light sensor is "seeing" the silver edge of the Robot Racing Arena. We need a switch so the our Robot will only turning left when it is above the silver edge. The following NXT-G commands could be used for this purpose:-

The command panel for the light sensor could be:-

 

This command panel setting will only turn left if the light value seen by the light sensor is greater than (see blue arrow above, ">" means "greater than") 50 (see the red arrow above).

The value of "50" may be OK if you are lucky, but you should always check the  lighting conditions for your room before using your Robot in a new environment.

To go to the next step and find out how to check the lighting conditions, click here.

Edge Following. - Tutorial 24 - NXT-G - LEGO MindStorms NXT - www.DrGraeme.net