The Arduino compatible STEM shield has lots of features like a temperature sensor, a 7-digit display, buttons, buzzers, etc. so you can make all different kinds of projects with one shield. And did you know that you can even make a line follower!? You can do this thanks to the on-board light sensor and IR LED that are tactfully placed on a separate part of the main PCB that you can break off. This way, you can mount the light sensor and IR LED on a practical spot of your line follower project.

In other words, this tutorial is ideal for anyone who wants to make their first line follower project with basic Arduino code.

What exactly is a line follower?

A line follower is a type of robot that will follow a white line on its own. The one we will be making uses an IR LED that will transmit infrared light and a light sensor that will detect reflected infrared light. Infrared light will reflect nicely on a white or light-colored area, but not on a dark-colored area. The light sensor will check whether or not the IR light is being reflected. If not, this means that there is no white line and the robot will go in a circle until it ‘finds’ reflected infrared light and thus the white line. If the light is being reflected, then the robot will keep on going in the direction of the white line.

For this project, we’re going to use the 2 Wheel Drive Motor Chassis Robotics Kit that includes all mechanical parts to make a motorized car or robot. We’ll show you how to assemble it and connect it to the Arduino, STEM shield and motor controller board.

The code that is needed for this Arduino project is also featured in this tutorial. So let’s get started!

1. Material



  • USB A to mini B
  • stripping pliers
  • soldering iron
  • solder
  • shrink tubes
  • heat gun or hairdryer
  • flat screwdriver
  • philips screwdriver
  • hot glue gun

2. Assembling the Line Follower

Firstly, you will need to assemble the robotics kit. This kit has its own manual which you can find here:
Follow the manual but do not execute step 5!

When finished, the robotics car should look like this:

3. Programming the Arduino and STEM shield

Not familiar with Arduino yet? Then check out their ‘Getting Started’ page here and learn how to program your microcontroller.

Download the example code here:  and upload it onto your Arduino board first.

4. Prepping the Connection

Check out the electrical connection scheme below and use it while following the steps below. Do not solder/connect it yet! To clarify, we will explain every step below.

5. Connecting the Electronics and Assembly

The robotics kit has a modular chassis that you can tweak to your needs. Because it is not made for one particular motor shield, we’ll have to adjust it a little so the motor shield that we’ll use can fit onto it. Therefore, you will need to drill an extra hole of 4mm in the chassis as shown in the picture. You can use the motor shield to estimate where to new hole needs to be. It should be about 50mm from the other hole that we’ll use (as shown in the picture). Tip: use a metal drill head.

Step 1: extend the wires from the 2 DC motors with about 15cm by using the soft electrical wire. Make sure you cover the connections with some heat shrink tubes!

Step 2: break off the line sensor from the STEM shield and extend it with 10cm of wire as shown in the picture.

Step 3: mount 2 spacers on the chassis as shown in the picture below.

Step 4: screw the Arduino Uno (or compatible board) into place.

Step 5: slide the STEM shield into the Arduino.

Step 6: lead the motor wires through the hole of the chassis to the top.

Step 7: lead the line sensor through the hole of the chassis to the bottom.

Step 8: again, mount 2 short spacers on the chassis. These will hold the motor board.

Step 9: mount the motor board on the spacers.

Step 10: connect the motor wires to the motor board screw connectors. (check the connection scheme)

Step 11: solder the + wire of the 9V-snap to one side of the power switch, then solder a wire to the other side of the power switch.

Step 12: secure the power switch to the chassis with a cable tie as shown in the picture.

Step 13: connect the – side of the 9V snap and + side of the power switch to the motor board (check the connection scheme).

Step 14: connect the jumper wires that run from the STEM shield to the motor board. (check the connection scheme)

Step 15: mount the 20mm spacer to the chassis.

Step 16: glue the line sensor onto the spacer.

Step 17: connect the battery and secure it with a cable tie.

Step 18: connect the power wires (green & white wire) from the motor board to the STEM shield’s Vin and GND pin. (check the connection scheme)

Et voila! The construction is finished and you can start making a route for the liner follower to follow. To clarify, the line follower works best when the underground is a dark color and the line is a light color. Because this line follower only has one sensor, it will move from side to side to check whether it is still following the line. Should you ever make another line follower with two sensors, then it should move straight forward.

Enjoy! And be sure to share your line follower with us on our socials!