nxtprograms.com

Fun Projects for your LEGO® MINDSTORMS® NXT!

Home     Projects     Help     Contacts

Line Follower
Building  
Programming  

Building Instructions

The Line Follower builds on the Classic Bot, so build that first.

Programming Instructions

Zigzag Line Following

Here is a simple program that will make the robot follow a line using a simple "zigzag" technique. This technique is not very smooth or fast, but it is easy to understand and program, so it is a good starting point. The program uses reflected light readings to make the robot follow the left edge of a dark line against a light background (or the right edge of a light line against a dark background).

Start with the robot aligned with the edge of the line.

Depending on the surface and line colors you use, you may need to adjust the light threshold number used in the Zigzag program. Ideally, the threshold should be set to the halfway point (average) between the lowest reading measured over the dark line and the highest reading measured over the light background. You can use this simple light meter program below to take your own readings. It takes and displays a reflected light reading each time you press the right arrow button the hub.

Smooth Line Following

This more complex program makes the robot drive faster and more smoothly than the zigzag technique. Whereas the zigzag technique is always turning either left or right (by a fixed amount), the smooth technique uses some math to constantly calculate an amount of steering to apply. It will go straight if the robot is directly on-course (centered directly over the edge of the line), steer only slightly if the robot is only a little off-center, and adding progressively more steering the farther off-center it is.

This smooth line follower also starts with an automatic calibration sequence to make the robot scan the line and the background to determine their brightness before starting (so using the Light Meter program is not necessary). For the smoothest start, start with the robot aligned with the left edge of the line.

Both programs above are adjusted for straight or gently curving lines.
For tighter curves, reduce the speed.

 

Home     Projects     Help     Contacts

 

Copyright © 2007-2021 by Dave Parker.  All rights reserved. 
All project designs, images, and programs are protected by copyright.  Please see the usage policy.