Arduino Line Follower Robot With Obstacle Detection

In previous projects, we talked about various Arduino basis Robotics projects. Now we are going to build a two-in-one robot which is an Arduino line follower robot with obstacle detection using some simple components. This is an autonomous robot that detects a black or white path and follows according to the path drawn. It follows the path with the help of an infrared sensor attached to the robot. The path can either be a black line or a white line, thus it avoids any detection errors.

This Line follower robot has an obstacle sensor (HC-SR04 Ultrasonic Sensor) that detects any type of obstacle in front of the robot so that there is no accident happening with the robot. Line follower robot is designed and programmed in such a way that it can follow the path without any errors. It operates in such a way that it detects and reads the path and transmits the signal to Arduino UNO. Then the microcontroller decides to make any changes in the directions and speed of the robot according to the inputs given by the Arduino. Thus, it sends the analog signal to the speed and directions of the line follower robot. To make a line follower robot with obstacle detection ability, it is attached with an ultrasonic sensor, which is a device that can measure the distance between an object and a robot sensor by using ultrasonic waves.

Must Read Line Follower Robot Without Microcontroller

Principle Behind Line Follower Robot

The Line Follower Obstacle Avoidance Robot consists of two infrared sensors and an HC-SR04 ultrasonic sensor attached to it. When the left IR sensor senses the black line, then the robot turns on the left side and if the right IR sensor senses the black line, then the robot turns the right side. Until both the left and right IR sensors sense the white area, the robot moves forward continuously. If the robot comes across a path where there is another black strip lying perpendicular to the path, then the robot stops at that moment.

Project

Arduino Line Follower With Obstacle Detection Robot
Arduino Line Following Obstacle Avoidance Robot


Circuit Diagram

Arduino Line Follower Robot With Obstacle Detection Circuit Diagram
Arduino Line Follower Robot With Obstacle Detection Circuit Diagram

Components Required

  • Arduino UNO
  • L293D UNO Motor Driver Shield
  • HC-SR04 Ultrasonic Sensor
  • Infrared Sensor Module (x2)
  • Geared Motor (x4)
  • Wheels (x4)
  • 3.7V Li-Ion Battery (x2)
  • Battery Box
  • Chassis
  • Connector Wires

About Parts of Line Follower Robot

Arduino

Arduino UNO
Arduino Nano

For the compact build, I choose Arduino Nano despite Arduino UNO. Arduino Nano is a small, flexible microcontroller board using an Atmega328p chip. It can also use as a substitute for UNO. All the functions are the same in these two boards. The size of its PCB is 18×45 mm. The clock speed is 16Mhz. Its input voltage is 5-12V. There are 30 pins including power pins, data pins, analog pins, serial pins on this board.

Ultrasonic Sensor

ultrasonic sensor
Ultrasonic Sensor

This is a sensor that can measure the distance of an object from the sensor position by ultrasonic sound waves. It sends ultrasonic waves of 40 KHz in the medium. If the waves are reflected on the object and bounce back to the sensor, it calculates the distance by calculating the travel time and speed of sound.

Infared Sensor

Infrared Sensor
Infrared Sensor

An infrared sensor module is an electronic device that emitted infrared rays for sensing. This sensor can sense any objects in the surroundings as well as measures the heat and motion of it. The working principle of this module is so easy. The IR transmitter sends the infrared rays and after a certain distance, it gets reflected by the object. These reflected rays get captured by the receiver present in this module. By this process, it captured data from the object.

L293D UNO Motor Driver Shield

L293D Motor Driver Shield
L298N Motor Driver

This is an L293D motor driver shield that can drive four motors, one stepper motor and two servo motors using Arduino UNO. Motors are arranged in a way called Half-Bridge. H-Bridge is an electronic circuit that enables a voltage to be applied across a load. It allows full control over a standard electric DC motor.

Note: I am using an L293D motor driver shield in this project, but you can also use an L298N motor driver as we use only four BO motors. But in the case of four BO motors for better result, we should use the L298N motor driver.

PCB Design

For removing messy wiring and give a clean look, I designed a PCB prototype for this project. It is also helpful for troubleshooting that runs great without any errors. To design this PCB board, I used EasyEDA as it is too easy to use. For ordering PCB for this, I prefer PCBWay.

Gerber file for Line Follower Obstacle Avoidance Robot Gerber.

PCB View

Line Follower Robot With Obstacle Detection 2D View
2D View
Line Follower Robot With Obstacle Detection 3D View
3D View

Order PCB From PCBWay

There are so many forums or communities for electronics online in today’s technical world, and one of the famous ones for PCB manufacturing is the PCBWay. PCBWay is a place that brings manufacturers and customers together. They have more than a decade of experience in this field of fabrication, prototyping and assembling PCBs. PCBWay have proved their focus to their customers’ needs in terms of cost-effectiveness, delivery, and quality.

How PCB Manufacturing Process Done in PCBWay

Standard quality for any product needs to be maintained using some parameters. PCBWay gives that opportunity by quality control in designing and manufacturing. At first, they ensure accuracy, clarity, validity of the PCB files that we sent to them.

Then all the boards will go through the most stringent tests other than the basic visual check. They adopt most of the testing and inspecting equipment used in the industry, such as Flying Probe Tester, X-Ray Inspection Machine, Automated Optical Inspection (AOI) Machine. PCBWay are having 50+ new engineers on the daily basis around the world using PCBs for their work, who trust for their reliable quality. They produce high-quality pink, orange, grey, even transparent solder mask. Moreover, according to people needs, they can also provide Black core PCB. Check it out for a High-Quality PCB solder mask. There are some pictures below of the new colours of solder musks.

Features of PCBWay

PCB Prototyping & Manufacturing: PCBWay produces FR-4 and Aluminum boards and advanced PCBs like Rogers, HDI, Flexible and Rigid-Flex boards, at a very reasonable price. Just check this Instant Quote to order premium PCBs for your hobby projects.

PCB Assembly: It not only offers PCB Prototyping but also offers PCB Assembly service. You can order a full PCB board with attached components by uploading your file. SMT & THT assembly starts from only 30$ including free stencil and worldwide shipping. The components can be sourced and provided by PCBWay, or by clients themselves.

Open Source Community: It not only offers PCB Prototype & Assembly service but also gives opportunities to students for sponsorships. I think this is so great. They feature their projects on the website also.

3D Printing & CNC: It also produces Rapid Prototyping like 3D printing, CNC Machining, Sheet Metal Fabrication, and Injection Molding. The quality of the product is too premium and reliable. And also the best part is that you will receive your order within a minimum of 3 days.

PCBWay Store: More boutique gift modules are waiting for you to discover, giving your creativity wings. You can order all types of electronic equipment, components and many more with exciting offers. Go with the link and buy your needs, PCBWay Store.

Services: PCBWay offers great servicing of their products. It takes only 3 to 15 days according to courier service to deliver your products. Also, it has a live support facility. Whenever you have any problems, you can always reach a live customer service person to respond to your emails or messages. They have the “Return and Refund” principle, for every unusable board caused by PCBWay, they will rebuild and refund the order soon.

Working Principle of Arduino Line Follower Robot

According to the above circuit diagram, we notice that a microcontroller (Atmega328p) is used to communicate with the whole system for processing the robotics functions. First, we need to connect both Vcc and ground pins of the Arduino Nano with a 9V power supply. As we know this is the main source for operating the whole system.

After connecting the above connection, let’s connect the L293D motor driver shield onto the Arduino UNO. Four geared motors are connected to the outer terminal of the motor driver as shown in the circuit diagram. This is a powerful motor driver that can drive four 6V motors easily.

After that, let’s connect the right infrared sensor’s data pin to the A0 pin and the left infrared sensor’s data pin to the A1 pin of the Arduino. It helps to detect the black line according to the robot’s path and let it rotate in the correct direction.

Next, we need to connect an Ultrasonic sensor for detecting obstacles in front of its path. Then we need to connect the “Echo” and “Trig” pins to the A4 and A5 pins of the Arduino respectively. It collects the signal by throwing an ultrasound to any obstacles in front of it and then sends this signal by the “Trig” pin. Thus the Obstacle Avoiding Arduino Line Follower Robot works.

Conclusion of Arduino Line Follower Robot

Thus, the line follower obstacle avoidance robot is successfully designed and implemented. We can use the advanced big version of this robot in public transport. It will easily be operated without any other devices like smartphones, remote control, WiFi etc. This is fully automatic according to the path which we gave for it using the Arduino microcontroller.

Application of Arduino Line Follower Robot

  • In a time of automation generation to reduce labour efforts, it is necessary to develop such type of robot, that can be used in airports to carry equipment and luggage from one place to another.
  • They are very useful as they can work without any supervision i.e. they work like fully automatic vehicles.
  • With additional features like obstacle avoidance and other security measures, we can use obstacle avoiding line follower system in a driverless car.

Install NewPing Library

Click here to install the NewPing Library file.

Arduino line follower robot newping library install

After finishing the download open Arduino IDE software.

Sketch>> Include Library>> Add .ZIP Library>> Select NewPing ZIP which you download recently>> Open.

Arduino Code