Lego NXT line following robot - Source Code

NXT_robot.nxc

I wrote this code as part of a group assignment for a computer science artificial intelligence paper I took at uni in 2009.

The robot is meant to follow a line which is a lighter colour than the rest of the ground. We used yellow masking tape on dark green carpet.

How to use:

Start the program
Put robot ON line and push LEFT bumper
Put robot OFF line and push RIGHT bumper
Put robot back on line and push left bumper again to start it.
The robot should then follow the line and (might) navigate around any objects in its path. If there are any gaps in the line it will move forward about 5cm or so and search for the line. If it finds the line, the robot will carry on as usual. If it doesn't find the line, it wanders off and does whatever it wants to do.

If you happen to be one of the other guys in the group (David, Kynan or Ross) and you want me to remove the code, please do notify me.

Here are some more Lego NXT resources.