SPIKE™ Prime Set

Training Camp 3: Reacting to Lines

Write programs using the Colour Sensor to make the Driving Base autonomous.

30-45 min.
Grades 6-8

Lesson Plan

1. Prepare

  • Read through the pupil material in the LEGO® Education SPIKE App.
  • You'll need a thick black line on a white or light surface for this lesson:

    ▷ Draw a black line on a sheet of white paper
    ▷ Use electrical tape on a light surface
    ▷ Print out the ‘line ideas’ PDF
    ▷ Use a spare black axle element from the LEGO SPIKE Prime Set

2. Engage (5 Min.)

  • Use the ideas in the ‘Ignite a Discussion’ section below to engage your pupils in a discussion relating to this lesson.
  • Use the video to explain the lesson.

3. Explore (20 Min.)

  • Have your pupils work in pairs to build the Driving Base with the Colour Sensor.
  • Ask them to play the first programming stack to move their Driving Base forward and stop perpendicular to a black line.
  • Have them try the second programming stack and describe what happens.

4. Explain (5 Min.)

  • Facilitate a discussion about how the Colour Sensor detects the black line.

5. Elaborate (15 Min.)

  • Have your pupils work through the next program to make their Driving Base follow a black line.
  • Ask them to optimise this code to create an even better line-follower program.

6. Evaluate

  • Give feedback on each pupil's performance.
  • In order to simplify the process, you can use the assessment rubrics that have been provided.

Ignite a Discussion

Use these ideas to engage your pupils in a discussion about competition fields and the lines that are often seen on them.

  • Ask your pupils how they could use these lines to help make their Driving Base program more effective.
  • Explain the different types of lines and intersections:

    ▷ Thin lines
    ▷ Right angles
    ▷ T-junction lines
    ▷ Non-continuous lines
    ▷ Black lines cut by a coloured line

Have your pupils watch this video to see what they're about to do.


Building Tips

A Simple Driving Base with the Colour Sensor
Use the simple Driving Base model with the Colour Sensor. Remember to use the cable clips.


Using the Colour Sensor
The Colour Sensor can be used in 2 different modes to solve this challenge (i.e. colour mode or Reflected Light Intensity mode).

The Reflected Light Intensity mode of the Colour Sensor will give maximum precision. Following a line is an alternating detection of 2 colours or 2 reflected light intensities. Spend some time with your pupils exploring the ways in which the sensor reports values. For example:

SPIKE Competition Ready Training camp 3 Teacher Building Tip en-au

Using the Motors in Power Mode
When turning on two motors using the Regulated Speed Mode of the Movement Blocks, the Hub will gradually send power (voltage) to the motors in order to reach the desired speed and keep it constant, regardless of whether the Driving Base is driving on a flat surface or a slope.

When turning on the two motors in the Power Mode of the Movement Blocks, the Hub will immediately send the desired power (voltage) to the motors.

In the case of a line-follower program, the Driving Base motors must perform small and fast movements (most likely below 10 degrees, to oscillate the Driving Base between the white and black spaces). In these situations, programming using Power Mode is recommended because it's more reactive, resulting in a more accurate line follower.

You'll find this block in the ‘More Movement Blocks’ extension.

Coding Tips

Main Program

SPIKE Competition Ready Training camp 3 Step03-Program en-au

Possible Solution

SPIKE Competition Ready Training camp 3 Teacher Solution en-au

Other Programs

SPIKE Competition Ready Training camp 3 Teacher Other en-au


Simplify this lesson by:

  • Explaining the Reflected Light Intensity mode of the Colour Sensor

    ▷ Find out more about the Colour Sensor in the help section of the SPIKE App.

Take this lesson to the next level by:

  • Challenging your pupils to modify their programs to follow lines of different sizes, colours and shapes.

Assessment Opportunities

Teacher Observation Checklist
Establish a scale that suits your needs, for example:

  1. Partially accomplished
  2. Fully accomplished
  3. Overachieved

Use the following success criteria to evaluate your pupils' progress:

  • The pupils are able to program their Driving Base to react to lines using the Colour Sensor.
  • The pupils can use an ‘IF / ELSE’ statement in their program to make a simple line-follower.
  • The pupils can optimise their line-following program to be more accurate.


Have each pupil choose the brick that they feel best represents their performance.

  • Blue: We've made our Driving Base stop at a perpendicular line.
  • Yellow: We've programmed our Driving Base to follow a line.
  • Violet: We've modified our line-following program to move our Driving Base faster and more effectively.

Encourage your pupils to provide feedback to one another by:

  • Having one pupil use the coloured brick scale above to score another pupil’s performance
  • Asking them to present constructive feedback to one another so that they can improve their group’s performance during the next lesson

Language Arts Extension

To integrate language arts skills development:

  • Present a program called ‘differentiated line follower’ (see the ‘coding tips’ section) and have your pupils try to decode how the program works.
  • Ask your pupils to evaluate the performance of this program compared to their previous line-follower programs.

Note: This will require additional time.

Maths Extension

To incorporate the development of maths skills:

  • Ask your pupils to use these terms to explain how a line-follower program works when using the Reflected Light Intensity mode of the Colour Sensor:

    ▷ Threshold value
    ▷ Mean value
    ▷ Greater than, less than
    ▷ Range
    ▷ Percentage

Note: This will require additional time.

The pupils who enjoyed this lesson might be interested in exploring these career pathways:

  • Information Technology (IT Applications)
  • Manufacturing and Engineering (Machine Technology)
  • Manufacturing and Engineering (Pre-Engineering)

Teacher Support

The pupils will:

  • Program their Driving Base to stop at a black line
  • Program their Driving Base to follow a black line

LEGO® Education SPIKE Prime Set

Australian Curriculum: Technologies
Design, modify and follow simple algorithms involving sequences of steps, branching, and iteration (repetition)
Implement digital solutions as simple visual programs involving branching, iteration (repetition), and user input
Implement and modify programs with user interfaces involving branching, iteration and functions in a general-purpose programming language

Student Material

Student Worksheet

Download, view or share the student worksheet, either as an online HTML page or a printable PDF

Share with:

Google ClassroomGoogle Classroom