Find the right line!

lesson-header

It's easy to win a car race. Mostly, you just have to be the fastest and stay in your racing lane.

Would it help if you could follow a line?

Build this Driving Base with a Colour Sensor.

student-02

Let’s do this!

Drive and stop at a line.

SPIKE Competition Ready Training camp 3 Step03-Program - en-gb
student-03

Try the first programming stack and describe what you see.

This first stack will make the Driving Base stop at a line that’s perpendicular to its movement.

The line can be:

  • A black line drawn on a piece of paper
  • Black tape
  • Larger black LEGO bricks

Drive on a line.

student-04

Try the second programming stack and describe what you see.  

If the Colour Sensor detects the edge of the black line, the Driving Base turns in the direction of the white space.

When the Colour Sensor does not detect the edge of the black line, the Driving Base turns in the opposite direction of the black line.

Repeat these 2 actions forever.

student-03-hint

Maybe you have noticed that we are steering the motors at a right 50 and a left -50. Do you know why?

It is necessary for the movement along the line to have one motor moving and the other motor stopped to allow the Driving Base to move forward. If the Driving Base turns too sharply, it will just turn back and forth in place.

Optimise your program for speed.

student-05

There are many ways to make a fast line-follower.

Organise a race to see whose Driving Base can go the fastest!

Add an ’IF / ELSE’ Block to speed up the execution of the program.

Keep exploring line-follower programs, you’ll be surprised how much you can improve your speed!

Your program could look something like this:

SPIKE Competition Ready Training camp 3 Step05-Hint - en-gb

How did you do?

student-06

What did you do well? Was there anything that you could have done better?

Brilliant! Now you should be able to move your Driving Base to almost anywhere on a playing field.