Introduction: Arduino Based Desktop Line Follower - JolliBot

One of the classic projects which may interest entry level robotics hobbyist is the line following robot which is more commonly known as a Line Follower. There are lots of kit sets available to build Line Followers but they are generally quite big and require line tracks covering a large area for the Line Followers to navigate on. Those that are small are usually intricate, used mostly SMD components, not micro-controller based for ease of programming and do not use batteries commonly available.

For this project, we from jolliFactory have designed yet another Line Follower which we have aptly named it jolliBot. The design is based on the following requirements:

  • Small and compact enough to navigate on moderately complex tracks occupying typical size table tops.
  • Uses all through-hole electronics components so someone with basic soldering skill should be able to put it together.
  • Uses a micro-controller with ease of programming which can easily be swap out for use on other projects.
  • Uses batteries which are easily available.
  • Light weight and inexpensive.

For those who prefer to purchase jolliBot as a DIY kit, you may find it at my Tindie store.

You may view the following jolliBot In-Action YouTube video to see what we are building.

Our Line Follower will not win you any prize in Line Following Robotics competitions since it lacks speed but hopefully it can be a good and inexpensive educational robot.

To build this project, you need to have some basic soldering skill, some knowledge on electronic circuits and is familiar using the Arduino micro-controller.

Step 1: Building JolliBot

It is quite simple to build a basic line follower as only few components are required:

  • a robot chassis
  • some sensors for line tracking (black or white lines)
  • two motors (servos or gear motors)
  • a micro-controller / electronic circuit to drive the motors and to implement control logic
  • Batteries, jumpers, screws and other hardware

For a very basic Line Follower, 1 sensor may only be needed to achieve line following function at low speed and on simple continuous tracks. Some advanced Line Followers employ a lot more sensors which are specially arranged to follow complex tracks at high speed.

For jolliBot, we will be using 5 TCRT5000 IR reflective sensors. It is common to use the 18mm wide black or white electrical insulation tape to build Line Follower tracks. For our Line Follower, the array of 5 sensors is arrange in a typical straight line formation at the front and are equally spaced 10.16 mm apart. This enables a maximum of 2 sensors to detect the 18mm wide line if the Line Follower is moving straight along the line. 5 sensors should be sufficient for us to experiment with a range of strategies for line following.

For the micro-controller, we will be using currently one of the more popular among hobbyist which is the Arduino Nano as it is relatively small and easy to re-program via USB.

For the motors, we will be using two micro DC planetary geared-motors operating at 5V DC which are available from Tindie fitted with 32mm diameter wheels.

The steering mechanism for jolliBot is realized in a differential drive that steer the robot by difference in rotation speed between the left wheel and the right wheel.

To drive the motors, we will be using the L293D H-bridge motor driver IC because Arduino cannot feed the motors directly with the high current required.

We can wire up the electronics circuit for our jolliBot Line Follower on perf-board no larger than 6cm x 6 cm. We will not be using a separate robot chassis and instead will be using the perf-board itself as the robot chassis. As it may be quite tedious to build the electronic circuit on perf-board, we have designed a PCB for those who do not want to mess around with too much wiring.

For power supply,do not use the usual 3 x AAA battery pack that is readily available which can output only about 4.5V. The output voltage is insufficient to reliably power the Arduino Nano. Here, we will be using a 3 x AAA battery power pack with built-in DC to DC Booster to supply 5V directly to the Arduino Nano as well as to drive the motors. This maintains a more constant input voltage to the electronic circuit as well as for the micro DC geared-motors. The 5V DC power pack is available at Tindie. You may also source for any other suitable 5V power packs for the project.

For audio output, we will be using a 5V buzzer . In our Arduino program, we have coded so that jolliBot shall emit some warning sound to alert that it is going to perform sensor normalization. User should then quickly place it around the center of the line and ensure nothing is obstructing its path for the process to be successfully executed.

It shall have 2 LEDs which act as the left and right front headlights. In our Arduino program, we have coded to just turn them on while following the line. You may program them to turn on or off based on some defined operations.

The layout location of the sensors and the motors mounted on the perf-board or on our custom PCB can be found in the attached images.

We will not be showing you the detail on how to wire up the circuit on the perf-board. You will need to figure out how best to build the circuit on the perf-board yourself based on the schematic diagram for jolliBot.

In the next section, we shall show how jolliBot is assembled using our manufactured PCB. Hopefully, this should be helpful if you are following this project wiring it up using perf-board.

As we mentioned earlier, you will need to have basic electronics knowledge in order to build the circuit on the perf-board based on the schematic diagram provided here.

Step 2: Part List for JolliBot

For those who would like to have jolliBot but do not have the time or skill to build the circuit on the perf-board or would like to have a more professional looking Line Follower, you may purchase the jolliBot DIY kit from Tindie.

The following are the parts required to build jolliBot:

  • 1 x Arduino Nano 3.0
  • 5 x 330 ohms resistor
  • 2 x 3.3K ohms resistor
  • 5 x 12K ohms resistor
  • 1 x 100 ohms resistor
  • 1 x 0.1 uF ceramic capacitor
  • 1 x 16 pin DIP IC Socket
  • 1 x L293D IC
  • 2 x LED (Super Bright Blue)
  • 1 x 2mm pitch JST straight PCB socket
  • 2 x 100 uF 16V electrolytic capacitor
  • 1 x 18 pin Single Row 2.54 mm Female Pin Header
  • 5 x TCRT5000 sensor
  • 1 x Buzzer 5V
  • 2 x 15 pin Single Row 2.54 mm Female Pin Header
  • 1 x Motor Binder Clip
  • 1 x Adhesive Clear Circular Bumper
  • 1 x Wire formed Stand-Off
  • 1 x Cable Tie
  • 1 x perf-board or jolliBot bare PCB

We are using super bright blue LEDs for jolliBot's headlights which we have used 3.3K resistors to limit the brightness. You will need to replace the value for this limiting resistor to suit the LED you may be using.

Step 3: Assembly of JolliBot

You may view the following YouTube video to see the assembly of the jolliBot DIY kit to better understand how jolliBot is build.

The following are the steps to be taken for assembly of jolliBot:

Caution: Identify the top and bottom of the PCB from the labels ‘TOP’ and ‘BOTTOM’ silk-screened on the PCB. Ensure you are on the correct side of PCB before proceeding to solder the components.

Step 1: Bend the five 330 ohms resistors and solder them upright to R1, R2, R3, R4 and R5 at BOTTOM of the PCB.

Step 2: Bend the two 3.3K ohms resistors and solder them upright to R11 and R12 at BOTTOM of the PCB.

Step 3: Bend the five 12K ohms resistors and solder them upright to R6, R7, R8, R9 and R10 at BOTTOM of the PCB.

Step 4: Bend the 100 ohms resistor and solder it upright to R13 at BOTTOM of the PCB.

Step 5: Solder the 0.1uF capacitor to C3 at BOTTOM of the PCB.

Step 6: Solder the 16 pins IC socket to IC1 at BOTTOM of the PCB. Ensure correct orientation.

Step 7: Insert the L293D IC into IC1 socket. Ensure correct orientation.

Step 8: Solder the two 5mm LEDs to LED1 and LED2 with the legs extending around 8mm above the top of PCB. Ensure correct polarity with longer lead of LED soldered to ‘+’. The LEDs need not be bent towards the front at this stage.

Step 9: Solder the battery socket to J4 at TOP of the PCB. Ensure correct orientation.

Step 10: Solder the two 100uF capacitors to C1 and C2 at BOTTOM of the PCB. Ensure correct polarity.

Step 11: Remove 8 of the pins from the 18 pins female header as shown in the figure below and then solder it across sensors S1 to S5 at BOTTOM of the PCB.

Step 12: Trim off both legs of the IR LED (blue lens) on the five TCRT5000 optical sensors to a length of around 6mm from the bottom of the black plastic housing. Insert the trimmed legs for each of the five TCRT5000 sensors into the 18 pin female header and solder the other 2 untrimmed legs to S1, S2, S3, S4 and S5 respectively on the PCB.

Step 13: Insert the buzzer from TOP of the PCB and solder the buzzer terminals from below. Ensure correct polarity (The ‘+’ mark on the top of buzzer should be left). Note that this is the most challenging task due to space constraint to solder the buzzer terminals.

Step 14: Solder the two 15 pins female headers to J1 and J2 at BOTTOM of the PCB. You may insert in the Arduino Nano into the female headers before soldering to hold the headers in place during soldering.

Step 15: Route the wires on the two wheel motors through the 2 holes near each end of IC1 and solder the motor wires to M1 and M2 on the top of the PCB. Ensure the black and red wire are soldered to the correct pins at M1 and M2 as shown in the figure.

Step 16: Use the metal binder clip to clamp the two wheel motors. Adjust the motors so that they are clamped as much as possible but there must be good clearance between the wheels and the PCB. Remove both clip handles.

Step 17: Paste the Adhesive Clear Circular Bumper onto the metal binder as shown in the figure below.

Step 18: Insert the Wire-formed Standoff into the 18 pin female header as shown in the figure below.

Step 19: Insert the Arduino Nano into the headers at J1 and J2 on the PCB. Ensure correct orientation.

Step 20: Loop the cable tie through the slots on the metal binder clip as shown in the figure and make a loop such that the cable tie loop size is just sufficient to insert the Power Pack through.

Step 21: Slide the 5V Battery Power Pack through the cable tie loop and trim off excess cable tie end. Plug the Power Pack connector into the J4 socket.

Step 22: Bend the 2 LEDs towards the front to complete the Line Follower.

Step 4: Programming the Arduino

In the jolliBot In-Action YouTube video, we have tested the Line follower with basic control as well as a more advanced PID control program codes. With the basic control, you may notice the jittery and wobbly movement of the Line Follower but with the more advanced PID control, there is a noticeable improvement in the speed and movement of our Line Follower.

For our basic control, we used only 3 of the line sensors for line detection, Left (S2), Center (S3) and Right (S4). When the Center sensor detects the line, the robot is programmed to go straight. When the Center sensor no longer detects the line but the Left sensor detects the line, the robot is programmed to turn right. When the Center sensor no longer detects the line and the Right sensor detects the line, the robot is programmed to turn left. This will typically cause the robot to wobble back and forth over the line and if going too fast, it may lose control and stop following the line.

You may download our Basic Line following Concept Arduino sketch below:


We know that it is possible to improve on the movement and speed of jolliBot with more advanced control algorithm as witnessed in the video. However, we will not be providing the more advanced Arduino code here. We hope you can research and come up with codes for jolliBot to improve its performance.

Step 5: Test Tracks

A line following track circuit can be created quickly using black electrical tape. It is a good idea to draw the track circuit out with a pen or pencil first and then paste the tape over the line.

We could also use printed track circuits which is also more convenient and the tracks will be more standardize for testing by anyone who have the same track circuit file.

The track circuit should have some features to test the ability of our Line Follower’s control loop.

We have designed two track circuits to test our Line Follower. JF Track #1 is a continuous line with straight and curved tracks. JF Track #2 is very much more challenging as there are line intersections and there are some right angled turns involved. You may download these test tracks below for printing. Each track is made up of 2 x A3 size pages.

JF Track #1 Left

JF Track #1 Right

JF Track #2 Left

JF Track #2 Right

Do note that the basic control Arduino sketch provided for jolliBot will not be able to manoeuvre successfully through test track #2 due to the sharp turns. So do not despair if this happens. You just need to improve the control codes.

Step 6:

Move It

Participated in the
Move It