How to make nxt robot follow a line


The original version by Lego uses the reflected light to distinguish between black the line and white the floor. When the sensor is on the white surface, the right motor is activated and the robot turns left. In this way, the robot follows the line. The approach is very simple and effective. However, as the robot only distingushes between black and white, the resulting movement looks as if it would be drunk.

The idea behind the new version is, not only to distinguish between black and white, but to consider various degrees of grey. If the sensor is exactly on the boundary, it will see a colour that is between black and white. However, as the robot only distingushes between black and white, the resulting movement looks as if it would be drunk. The idea behind the new version is, not only to distinguish between black and white, but to consider various degrees of grey.

If the sensor is exactly on the boundary, it will see a colour that is between black and white. The more the sensor gets on the line, the blacker the perceived colour is. On the other hand, the more the sensor gets on the white surface, the whiter the perceived colour is.

This is called Fuzzy Logic as we do not consider absolute states Boolean Logic, here "Black and White" but different degrees of those states Whiter, Blacker. Now we are not limited anymore to turn only left and right, but can turn more right blacker colour or more left whiter colour.

The more the sensor gets on the line, the blacker the perceived colour is. On the other hand, the more the sensor gets on the white surface, the whiter the perceived colour is. This is called Fuzzy Logic as we do not consider absolute states Boolean Logic, here "Black and White" but different degrees of those states Whiter, Blacker. Now we are not limited anymore to turn only left and right, but can turn more right blacker colour or more left whiter colour.

In this way, if exactly on the colour boundary, the robot runs straight ahead. The program consists of three loops that run at the same time. The first loop reads the current reflected light value and stores it in the variable called "Number 1".