Place the light or colour sensor if have the version 2.0 installed on your robot to make sure it is pointing at the ground. Mount the sensor right in front of and between the wheels, as near the ground as you can. Put the sensor on to the NXT brick. In addition to this, draw a line on a piece of paper so that the robot can follow that. The line needs to be around ½ inch wide and should not have any sharp turns. The radius of the turns should be more than half the width of the robot.
Switch on the NXT brick and choose the View sub-menu. Click on the Reflected Light icon and choose the port to which the light sensor is connected. Place the sensor over the paper and write down the reading on the NXT brick screen. Mount the sensor over the line you drew in the last step and write down the new reading as well. On the other hand, build a programme for your robot. Then have the robot drive the left wheel forward when the sensor gets over the line and the right wheel forward if the sensor goes out on to the blank piece of paper.
Sensors and movement of the robot
Once you have done the basics, put the robot on the piece of paper with the sensor only to the right of the line. After that, switch on the NXT brick, choose the programme you have made in the previous step and run it. Remember that the robot will perform according to the function installed and nothing more.