Saturday, 9 April 2011

Line Follower - Bit Logic Method



I have been tasked to teach one of the most fundamental programming ideas, Line Follower.

Before we begin, we should understand what Line Follower algorithm there is, and what is the best and quickest method. So today we will explore the easiest one of them all, the 2 bit line follower algorithm.



View the image above, the Black Box represents an enlarged Black line, while the tiny Red line represents where the light sensor is on and what it will see. You will notice from the video above, you will notice that the NXT Mindstorms actually makes very tiny zig-zag along the black line. If you look closely, it is actually like the red line above.

The idea is simple, if the sensor is over White (Point 1), you turn right towards the Black area. When you are over the Black (Point 2), you turn left towards the White area. Effectively you are hugging the left edge of the Black line.


Using just the a simple Switch Block, and 2 Move Blocks, we are able to program the bit logic line follower, as explained in the previous paragraph.

Being the easiest line follower algorithm to understand and teach doesn't make it the fastest. It only manage to complete the track in about 2 minutes, which is extremely slow!

No comments: