Please find a printable version of this practice task HERE.
Task Description
This task is great practice that shows how the Color Sensor can be used to guide the robot’s movements when following a black line. With the color sensor, the robot can “see the line” and follows it in a Zig-Zag-motion.
The task introduces an application of the Color Sensor and teaches learners how to use IF-THEN-ELSE logic. Also, fine-tuning of the motors is required to keep the robot on track.
This example is great practice that shows how the Color Sensor can be used to guide the robot’s movements, i.e., along a black line.
Materials Needed
- EV 3 Robot
- Color Sensor, attached to robot
- Black tape or black marker
To get started, attach the Color Sensor to the robot in base configuration. The sensor should be facing downwards and should be positioned less than 1 cm above ground. Find a creative way to attach the sensor yourself, or refer to pp. 68-72 of the EV 3 Manual (Building Instructions).
Then, put black tape on the floor to create a path or use marker to draw a wide black line: 2 cm width should do.
Programming the Robot to Move Along a Black Line
1) First, put a <IF-THEN-ELSE> Block inside a Forever <Loop> Block.
Set up the <IF-THEN-ELSE> Block for the Color Sensor and select “black”.

2) Next, make sure the correct port is selected. The sensor ports on the back of the robot are 1 – 4.

3) Then, add two <Move> Blocks. There are many options to have the robot follow the line and you have to fine-tune the <Move> Block settings (steering, rotations, power).
In our first example, the robot follows the line smoothly, but curves and sharp turns can be a problem.

In our second example, the robot follows the line precisely, but the forward movement is less smooth.

Please find a printable version of the “Moving along a Black Line” task HERE.
© 2022 Dr. Krista Francis & Stefan Rothschuh
Recent Comments