Line sensor vs Optical shaft encoder

During the autonomous period could anyone recommend whether the line sensor or optical shaft encoder (or something else) would be best for trying to place the cubes in a goal. From the game instructions it looks like the line is white but the description of the line sensor says that it’s for following a black line.

Its a white line.

I would say encoders are more useful in 15 seconds then relying on the line sensor. Make sure you read a guide about how to interface the encoders.

In my opinion the shaft encoder would be simpler. Even though the playing field is supposed to be just a white line on a black surface there is always a chance for error… i.e a beam of bright light from a window or wrongly colored tiles.
The shaft encoder is the same every time.

IMO, if programmed well both are equally effective.

It really doesn’t matter whether or not the line is white or black as long as the area surrounding the line is the opposite color. There needs to be contrast.

If there are two different colors. How do you tell it to follow one color insted of the other?

I use the Line sensors with gray foam tiles to detect white and black tiles so it should work fine for you. Compared to the gray foam tiles, there will be plenty of contrast to easily detect the white tape.

To account for the ambient lighting, I would suggest that your code should look for anything lower than a certain value. That’s what I did for my code at home, but I had the advantage of checking to see what kind of values I got from the sensors with the tiles first.

Having two different colours is not the same as having 2 contrasting colours. Distinguishing between red and purple is not the same as black and white.

The line trackers are photoresistors - they have different resistances based on how much light goes through - and from the voltages they are assigned an integer (the lower the brighter). Since there are 3 in a kit, telling the robot how to sense a line is basically changing where your robot goes based on the differences between the numbers.

For example: If your 3 readouts (from left to right) are 0-0-255, then the darkest part (and probably a black line) is on the right side. If it was a white line on a black surface the reading would probably be 255-255-0. Since there is always ambient light and the tiles are more of a grey than a black you would have to change your numbers a little.

Hope this helps!
(phew, longest post)


Colors and such do effect the performance of the line sensors. But so does the ambient light. There is a lesson that I learned from a Lego team that used light sensors to navigate the game table.

This team discovered to their horror that their cafefully crafted line-sensing robot simply did not work under the bright lights at the tournament location. However, back at their school room under different lighting conditions it worked fine.

To solve the problem the team added a dedicated sensor that they made sure was placed over a white area on the table each time they power the robot on.

At startup, the dedicated sensor took a reading of the ‘white’ on the table. This reading was then stored and used throughout the rest of the program to judge ‘white’.

So if you want to use light sensors be sure you have some way to make them self-adjusting to changing lighting conditions or you may have an unhappy surprise.