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 the 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:

  • Drawn on the table
  • Drawn on a piece of paper
  • The black axle element

Drive on a line.

student-04

Try the second programming stack and describe what you see.

When 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 detects the white space, the Driving Base turns in the other direction, towards the edge of the black line.

Repeat these 2 actions forever.

student-03-hint

You might have noticed that we're using Power Mode to switch the motors on. Do you know why?

Your Driving Base must perform a combination of small and fast movements (most likely below 10 degrees each time between the white and the black spaces). Programming using Power Mode results in a more reactive and accurate line-follower program.

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’ve done better?

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