Colours and Lines

Use the Colour Sensor to detect and follow lines.

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

Lesson plan

1. Prepare

  • Read through the pupil material in the EV3 Classroom App.
  • Collect information about how the Colour Sensor works, and how the Colour and Reflected Light Intensity Modes could be used.
  • You’ll need black electrician’s tape to create a thick black line.
  • To complete this lesson, the pupils will have to have built the Driving Base model, which will take about 30 minutes to complete.

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.
  • Divide your class into teams of two pupils.

3. Explore (20 Min.)

  • Have each team build the Colour Sensor Down extension for their Driving Base.
  • Allow the pupils time to use the programming stacks that have been provided to explore how the Colour Sensor can be used to detect and follow a line.

4. Explain (10 Min.)

  • Have your pupils use the programming stacks to calibrate the Colour Sensor and then observe its effect.
  • Facilitate a discussion about why it’s important to calibrate the Colour Sensor.

5. Elaborate (10 Min.)

  • Challenge the pupils to program a better line-follower program.
  • Don’t forget to leave some time for tidying up.

6. Evaluate

  • Give feedback on each pupil’s performance.
  • To simplify the process, you can use the assessment rubrics that have been provided.

Ignite a Discussion

Hardcoding the exact movements that a robot must make isn’t very efficient. Therefore, robots have different guiding systems to help them navigate their environment. One simple yet effective option is to use coloured lines on the floor, which a robot can follow using a sensor.


Use these questions to engage your pupils in a discussion about robots that can detect colours:

  • Do you know of any robots that can detect colours?
  • What are the advantages and limitations of using coloured lines as a means of navigation?
  • What’s reflected light intensity, and how does a Colour Sensor work?

Building Tips


Building Instructions

Keep the Driving Base assembled after use, rather than taking it apart.

Setting Up the Path
Provide your pupils with black electrician’s tape to use for creating a thick black line to detect and follow. Allow them to explore different types of lines but advise them that very sharp angles are hard to follow.

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.

Coding Tips

Main Program

EV3 Classroom-Programs 1-4-program en-gb

Possible Solution

EV3 Classroom-Programs 1-4-solution en-gb


Simplify this lesson by:

  • Explaining the Colour Sensor’s Reflected Light Intensity Mode
  • Simplifying the line that the Driving Base should follow

Take this lesson to the next level by:

  • Challenging your pupils to modify their programs to follow lines of different sizes, colours and shapes
  • Presenting a program called simple proportional line follower (see the Coding Tips section above) and having your pupils try to decode how the program works

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 Bases to react to lines using the Colour Sensor.
  • The pupils are able to calibrate the Colour Sensor and explain the importance of sensor calibration.
  • The pupils are able to optimise their line-following programs to be more accurate.

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

  • Bronze: I’ve made the Driving Base stop at a line.
  • Silver: I’ve programmed the Driving Base to follow a line.
  • Gold: I’ve programmed the Driving Base to follow a line and I’ve calibrated the Colour Sensor to account for changing light conditions.
  • Platinum: I’ve not only programmed the Driving Base to follow a line and calibrated the Colour Sensor to account for changing light conditions, but I’ve also optimised it to move the Driving Base faster and more effectively.

Language Arts Extension

To incorporate the development of language arts skills:

  • Have your pupils create a program called simple proportional line follower (see the Coding Tips section above) and create a presentation explaining how the performance of this program compares to their previous line-follower programs.

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

Computing at School Progression Pathways


  • Designs solutions (algorithms) that use repetition and two-way selection i.e. if, then and else.
  • Uses logical reasoning to predict outputs, showing an awareness of inputs.
  • Designs solutions by decomposing a problem and creates a sub-solution for each of these parts.
  • Recognises that different solutions exist for the same problem.
  • Recognises that different algorithms exist for the same problem.

Programming & Development:

  • Creates programs that implement algorithms to achieve given goals.
  • Uses post-tested loop e.g. ‘until’, and a sequence of selection statements in programs, including an if, then and else statement.
  • 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.
  • Understands that programming bridges the gap between algorithmic solutions and computers.
  • Uses a range of operators and expressions e.g. Boolean, and applies them in the context of program control.

Hardware & Processing:

  • Knows that computers collect data from various input devices, including sensors and application software.

Information Technology:

  • Makes appropriate improvements to solutions based on feedback received, and can comment on the success of the solution.
  • Uses criteria to evaluate the quality of solutions, can identify improvements making some refinements to the solution, and future solutions.
  • Designs criteria to critically evaluate the quality of solutions, uses the criteria to identify improvements and can make appropriate refinements to the solution.

Pupil Material

Student Worksheet

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