Table of Contents

Pixy2 LEGO Line Following Demo

This page describes how to make a LEGO robot that follows lines and makes turns at intersections as instructed. It's meant to be a basic introduction to the Pixy2's line following abilities.

Building the robot

The robot we're going to build can be found in Laurens Valk's book LEGO Mindstorms EV3 Discovery Book. The robot is called the Explor3r and it uses parts that are available in the retail Mindstorms EV3 kit.

Cables (IMPORTANT!)

Load Line Following Example

Troubleshooting

Making Turns at Intersections

If your line drawing has an intersection, you can tell your robot always turn left or always turn right (for example) by “hard-coding” the Turn Angle. With the program stopped, try setting the Turn Angle to -90 degrees.

-90 degrees is a right turn according to the diagram below.

Angle coordinates from Pixy2's perspective.

Re-run the program and notice that when it sees the intersection it will choose the right-most branch of the intersection and continue. In other words, it will always turn right when encountering an intersection. And more specifically, it will choose the branch that is closest to -90 degrees. Try setting the angle to 90 degrees and see what happens.

What's Next?

Can you extend this demo to make turns based on barcodes? Barcode images (including roadsigns!) are available here.