SPIKE™ Prime Set

Training Camp 3: Reacting to Lines

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

30-45 min.
Years 7-9 or Key Stage 3

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 Core Set

2. Engage (5 Min.)

  • Use the ideas in the Ignite a Discussion section below to engage your pupils in a discussion related 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 Colour Sensor.
  • Ask them to play the first programming stack to get their Practice Driving Base to move 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 get their Driving Base to 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 Colour Sensor’s Reflected Light Intensity Mode 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-gb

Using the Motors in Power Mode
When turning on a motor using the regulated speed mode, the Hub will gradually send power (voltage) to the motors to get to the desired speed and keep it constant, regardless of whether the driving base is driving on a flat surface or on 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-gb

Possible Solution

SPIKE Competition Ready Training camp 3 Teacher Solution - en-gb

Other Programs

SPIKE Competition Ready Training camp 3 Teacher Other - en-gb


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

  • Pupils can program their Driving Base to react to lines using the Colour Sensor.
  • Pupils can use an "IF ELSE" statement in their program to make a simple line-follower.
  • 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.
  • 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.

Peer Feedback
Encourage your pupils to provide feedback to one another by:

  • Having one pupil score the performance of another using the coloured brick scale above
  • Asking them to present constructive feedback to each other so that they can improve their group's performance during the next lesson.

Language Arts Extension

To incorporate the development of language arts skills:

  • Present a program called differentiated line follower (see 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 make for a longer lesson.

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 of the Colour Sensor:

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

Note: This will make for a longer lesson.

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

Pupils will:

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

CAS Computing Progression Pathways
Uses logical reasoning to predict outputs, showing an awareness of inputs. (AL)

Programming and Development:
Understands the difference between, and appropriately uses if and if, then and else statements. (AL)

Uses a variable and relational operators within a loop to govern termination. (AL) (GE)

Uses a range of operators and expressions e.g. Boolean, and applies them in the context of program control. (AL)

Programming and Development:
Knows that computers collect data from various input devices, including sensors and application software. (AB)

Information Technology:
Uses criteria to evaluate the quality of solutions, can identify improvements making some refinements to the solution, and future solutions. (EV)

Pupil Material

Student Worksheet

Download, view or share as an online HTML page or a printable PDF.