A Right Turn - Coping With The Black...

If our Robot was in the position shown below, (with the light sensor over the black portion of the arena), we would want our Robot to  turn to the right (clockwise), as shown in the image below. This would bring our Robot back to the edge of the silver strip that surrounds our Robot Racing Arena.


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

NXT-G Commands for Turning Right.

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:-


To remind you, 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.

The speed has been cut down to 50 to allow us to more easily see how the Robot is behaving.

Turning Right for Ever?

To make sure our Robot does not turn right for ever, we can place it in the lower section of the NXT-G switch we used on the previous web page, as shown below.

The bright symbol pointed to be the red arrow is supposed to remind you that this branch of the switch is for bright sensor values. The symbol pointed to be the blue arrow is supposed to remind you that this branch of the switch is for dark light sensor values.

The only thing to add now is a loop, to allow your Robot to keep going around the edge of your Robot Race Arena until you decide to stop your Robot.

To see a video of how your Robot may look running around the edge of the arena,  click here.

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