Jul 6, 2006

Line Follower program

Some reader (jeff) has posted a link to a Line Follower program for the NXT, written in NXT-G.
As it was published in a comment to a blog entry regarding a completely different topic, I thought it worthwhile to give this one its own homeland here, making it less likely to be missed by readers and easier for discussions.


Anonymous said...

those two seconds at the begining of the program are a really good idea

Anonymous said...

Great!! Better than the RIS 2.0's line follower program.

Rick Rhodes said...


Thanks much for posting the source code for this program.

Since books for NXT-G are non-existent (right now), the best way to learn code is to look at the examples of others.

jeff said...

After further testing and some code review, I have made few more changes. I think the line follower program is pretty much optimized as much as possible.

Much can be done to augment the line follower program. You can add more blocks to allow the robot to turn back and forth only a few times looking for the black line. Then have the robot move in a bigger search pattern looking for the line.



Mauricio said...

You guys excuse me for posting this here, I did not found where else to post it.

Have any of you recently clicked in the mindstorms.lego.com page, the section that says "What is NXT?" in the "do!" text?

I did not know the AlphaRex could do those things!!!

kert said...

at the end it says:
''Build and program robots
that do almost what you want''

kert said...

sorry, ''that almost do what you want.''

Rick Rhodes said...


I tried your "line follower" program--it works great!

Even the presence of strong ambient light doesn't affect the light sensor (as long as it's calibrated).

Matthias Paul Scholz said...


I think it important to make clear that I am not related to the line follower program in any way - it's entirely Jeff's thing.
I've just extracted the link Jeff posted recently into its own blog entry.

Rick Rhodes said...

Point taken...thanks, Jeff!

jeff said...

As a continuation of state machine ideas, I've added a program for controlling the RoboArm T-54 from the Robo Center challanges. This program more fully illustrates the technique of state machines in software that controls machinery. The program is available at


Anonymous said...

its a good line follower but i put a wait for center button push instead of a wait for 2 seconds.

KILE said...

I've just posted in my website the source code and videos from my LEGO line follower robot, maybe could be insteresting for someone:

Marc-Andre said...

ahh well it's been almost 5 years and now that link is non existent.. Jeff if you ever read this is your work still avail from another site these days?

Related Posts Plugin for WordPress, Blogger...