We have now reached a century where large industries are focusing more on being automated than increasing the workforce. A warehouse needs to be systematically arranged and the goods/inventory needs to be transported across from one location to the other. These requirements have led to the advent of Automated Guided Vehicles which maneuver over the place by following particular lines. Now, here, in this module, we will be learning about making a line-follower robot which can serve as a small prototype for what they actually use in warehouse automation.

Click the link to check out the ‘Robocraze DIY Line follower kit using Arduino UNO

We will be using the following components:

Unboxed DIY Line follower kit.


  • Arduino Uno (with cable)
  • L293D Motor Driver Shield for Arduino
  • Range adjustable IR sensor (x4)
  • Baseboard (x1)
  • Encoder disc (x2)
  • Deceleration DC Motors (x2)
  • Battery container (x1)
  • Wheels (x2)
  • Hammer castor (x1)
  • Jumper wires: male-to-male|male-to-female|female-to-female (x10)
  • Switch (x1)
  • Spacers (x4)
  • Fasteners (x4)
  • M3*30 screw (x4)
  • M3*8 screw (x20)
  • M3 nut (x18)
  • L12 spacer (x4)


We start off by the assembly of the two-wheeled drive DIY kit. We first connect the motors to the board by putting the fastener in the given slots and tightening them with M3*30 screws. Now, the wheels can be attached to the motors. Besides the two wheels, we are also provided with a hammer castor wheel which serves to support the motion of the robot by following the other two wheels while in motion. The castor wheel is attached along with the spacers provided, this maintains the height of the castor and keeps the robot in a fixed horizontal plane. Now that all the moving parts are taken care of, we come to the power supply which is provided with the help of 4 AA batteries. The battery container for the same is also provided with the DIY kit, it can be attached on the top. Note that the AA batteries are not necessarily the only power source to be used, we can use a 9V battery as well. If you have worked on with Arduino and motors, it will be conspicuous in your that using either 4 AA batteries or one 9V battery won’t last long. What can be done better is using the 9V battery to supply power to Arduino and the AA batteries for the motor driver, or you can use some good current rating AA batteries only.

 Assembled Line-Follower Bot

A completely assembled line-follower robot

So, by now, we have one easily assembled two-wheel drive robot. We now come to the electronics part. Take the Arduino and screw it to the baseboard (or you can use a double-sided tape as well). When done, attach the L293D Motor Driver Shield on the top of Arduino, making sure that corresponding pins in both are correctly connected. Take two wires each from both the motors and connect them to the motor driver shield placed on Arduino (say, M1 and M2). Check the connections for the same direction of motors as opposite polarity can cause counter motions. Now, we will shift our focus to the IR sensors which we place in the front. Two of them are used and both try to make bot move in such a way that the line it is traveling on is always in between the two. Connect the 5V and GND pins of the sensors to the 5V and GND points given in the shield. The input signal from the IR sensors is given through the Analog pins (here, we have used A0 and A1).

Through the serial monitor on Arduino IDE, we check the values of IR sensors when on the line and when not on the line. And, accordingly, we write a code with ‘if-else’ statements to make the bot move forward or turn left/right. The libraries for the motor driver shield can be downloaded online or directly go to this download URL: . Include the libraries for the DC motors, define an object for each and also declare pins for the sensor. You can see the complete program below:

Arduino code

The speed of the motor can be varied according to the requirement and the accuracy required and, similarly, the IR sensor values can also vary depending on the color of the path and can be utilized for multiple purposes.

Hoping this to be a great learning experience for the user… Thank you!


Leave a comment

Please note, comments must be approved before they are published