Colors and Lines

Use the Color Sensor to detect and follow lines.

45-90 min.
Grades 6-8

Lesson plan

1. Prepare

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

2. Engage (5 Min.)

  • Use the ideas in the Ignite a Discussion section below to engage your students in a discussion related to this lesson.
  • Split your class into pairs.

3. Explore (20 Min.)

  • Have each pair of students build the Color Sensor Down extension for their Driving Base.
  • Give the students some time to use the programming stacks provided to explore how the Color Sensor can be used to detect and follow a line.

4. Explain (10 Min.)

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

5. Elaborate (10 Min.)

  • Challenge the students to program a better line-follower program.
  • Don’t forget to leave some time for cleanup.

6. Evaluate

  • Give feedback on each student’s performance.
  • You can use the assessment rubrics provided to simplify the process.

Ignite a Discussion

Hardcoding the exact movements that a robot has to 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 colored lines on the floor, which a robot can follow using a sensor.


Use these questions to engage your students in a discussion about robots that can detect colors:

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

Building Tips


Building Instructions

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

Setting Up the Path
Provide your students with black tape to create a thick black line to detect and follow. Let them explore different types of lines but advise them that very sharp angles are hard to follow.

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

The Reflected Light Intensity Mode of the Color Sensor will give maximum precision. Following a line is done by alternating the detection of 2 colors or 2 reflected light intensities. Spend some time with your students exploring how the sensor reports values.

Coding Tips

Main Program

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

Possible Solution

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


Simplify this lesson by:

  • Explaining the Reflected Light Intensity Mode of the Color Sensor
  • Simplifying the line that the Driving Base should follow

Take this lesson to the next level by:

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

Assessment Opportunities

Teacher Observation Checklist
Create a scale that matches your needs, for example:

  1. Partially accomplished
  2. Fully accomplished
  3. Overachieved

Use the following success criteria to evaluate your students’ progress:

  • Students can program their Driving Base to react to lines using the Color Sensor.
  • Students can calibrate the Color Sensor and explain the importance of sensor calibration.
  • Students can optimize their line-following program to be more accurate.

Have each student 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 calibrated the Color Sensor to account for changing light conditions.
  • Platinum: I’ve not only programmed the Driving Base to follow a line and calibrated the Color Sensor to account for changing light conditions, but I’ve also optimized it to move the Driving Base faster and more effectively.

Language Arts Extension

To integrate language arts skills development:

  • Have your students 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 make for a longer lesson.

Students 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

Students will:

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

Develop a model to generate data for iterative testing and modification of a proposed object, tool, or process such that an optimal design can be achieved.

2-AP-12 6-8
Design and iteratively develop programs that combine control structures, including nested loops and compound conditionals.

Common Core
Present claims and findings, sequencing ideas logically and using pertinent descriptions, facts, and details to accentuate main ideas or themes; use appropriate eye contact, adequate volume, and clear pronunciation.

Interpret statements of inequality as statements about the relative position of two numbers on a number line diagram. For example, interpret -3 > -7 as a statement that -3 is located to the right of -7 on a number line oriented from left to right.

Student Material

Student Worksheet

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