The light sensor is focused on a wheel. The wheel is connected to the engine. On this wheel are three white and three black dots (see figure). The white and black colors were chosen because the robot the differences in color faster registered as the contrast is greater.
Each round which the wheel rotates is therefore a high three times, three times and a low light value measured. If a black dot is the light sensor, the sensor by a value of 48. In a white dot is the number 62. The programming code is the limit so put on 55.
Because the Lego-block is not very much power, the speed itself is not calculated. There are limits to work, the time between two white dots smaller than 0.02 seconds, then turns the engine too quickly. Is it time greater than 0.06 seconds, then he turns to slow.