In today's world, many researchers and engineers are working on automation systems that help to reduce labour and yield results with high efficiency. An automation system can operate one or more devices automatically, in a systematic way without required human efforts or interventions. A primary example of an automation system is Car Automation. Imagine that you have a car which can start on its own and follows a correct path to help you reach your destination. Sounds great?
So, in this blog you'll learn to make your own basic Car Automation DIY project in which an automated car robot will follow a black line path on its own.
In this tutorial, I will teach to build this automatic black line follower car robot with some basic concept of the Microcontroller, Arduino, and few other basic electronic components.
I have listed out the important components which we are going to use in making this DIY line follower robot.
Arduino Nano: Arduino Nano is a development board based on AtMega328 microcontroller which will control all commands of the line follower robot. It has input/output pins that are easily programmable as we want by using of Arduino Integrated Development Environment(IDE).
Buy it here: Arduino Nano Microcontroller
L298N Motor Driver: This motor driver drives the motor at high voltage with appropriate current supply. It also has a speed controlling feature with the help of a pulse width modulation(PWM). We will use it because the Arduino Nano cannot supply the required current directly through the Input/Output pins (I/O Pins) to the motors.
Buy it here: L298 Motor Driver Module
IR Sensor (2): IR sensor stands for Infrared sensor. An IR sensor consists of two important parts. The first one is an Infrared LED (Transparent color) which produces infrared rays. The second one is the photodiode (Black color) which receives the IR rays and generates some voltage difference at the output pins.
Buy it here: Infrared LED Module
- DC Gear Motor (4): Gear motor is the combination of a brushed DC electric motor and gear. It can provide 200 RPM with good torque on the crankshaft. It is also known as BO motor.
Buy it here: Dual Shaft BO Motors (DC Geared Motors)
Wheels (4): 65mm diameter wheel which can be easily attached to DC gear motor crankshaft.
Buy it here: Robotic Car Wheels
- Chassis with Fittings: The chassis is the supporting frame of the robot car where we can attach other components. In this experiment we have used an transparent acrylic chassis.
Buy it here: Four Wheel Chassis with Fitting
Jumper Wires: Jumper wire is a 15-20 cm long single strand wire with an stripped end. We will use it for making the connections of the line follower robot.
Buy it here: Male-to-male and male-to-female jumper wire
Bread Board 170 Points (2): Breadboard is a plastic board with a bunch of holes and these holes are internally connected in series. We will use a breadboard to attach the Arduino Nano with other components and some extra connections.
Buy it here: Bread Board 170 Points
Li-ion Cells (2): Li-ion cells are rechargeable cells. We will use two 18650 Li-ion cells in series for powering the motor and Arduino board. The total nominal output voltage is 7.4V which is appropriate for our powering system. We have used Li-ion cells because they are rechargeable, and can be reused in further projects when a charging circuit is available.
Buy it here: 3.7V 1200mAh Lithium-ion cell
Battery Holder: We will use a two-cell battery holder. Which provides two terminal of battery of 7.4 V potential difference.
Buy it here: 2 Lithium Ion Cells Battery Holder
Arduino IDE: The Arduino Integrated Development Environment (IDE) is an open-source software where we can write the program in the high-level language with some instruction set of Arduino. It compiles the program and fetches into the Arduino with the help of a Mini B USB cable.
You can download the Arduino IDE software from here!
Don’t worry guys, if you are new to the Arduino Nano, check out this link for more knowledge about the Arduino Nano.
Click here to know more about Arduino Nano!
First, we will understand the connection between Arduino Nano and other peripherals.
- Fix the Arduino Nano on the breadboard.
- Remove the jumpers from the Enable Pins (EN1, EN2) of the L298N Motor Driver.
- Connect EN1, EN2 of L298N to D3, D11 of Arduino Nano, respectively.
- Connect 1N1, 1N2, 1N3, 1N4 of L298N to D4, D5, D6, D7 of Arduino Nano, respectively
- Join the terminals of left-sided motors and connect the left side motors terminal to OUT1, OUT2 of L298N motor driver, respectively.
- Join the terminals of right-sided motors and connect the right side motors terminal to OUT3, OUT4 of L298N motor driver, respectively.
- Connect the OUT, VCC, GND of the left IR sensor to D12, VCC, GND of Arduino Nano respectively.
- Connect the OUT, VCC, GND of the right IR sensor to D13, VCC, GND of Arduino Nano respectively.
- Connect the Vin, GND of Arduino Nano to positive (+ve), negative (-ve) terminal of the battery holder, respectively.
- Connect the VS (12V), GND of L298N motor driver to positive (+ve), negative (-ve) terminal of the battery holder, respectively.
So, we have done the connection. Furthermore, in order to know how the whole system will be going to work and why we are using the IR sensor for our automatic system, I'll explain everything steps by step.
In the automatic line follower car robot, we need something which can sense the black line. For that, we can use an IR sensor. IR sensor detects the object near about 5 to 6 cm.
Basically, the infrared LED transmits the infrared rays and bump to the object. After the collision, it will reflect back and capture by the photo-diode and produces a very small amount of potential difference. Which can further amplify with the help of a differential Amplifier. We can sense this potential difference at the OUT pin of the IR sensor.
In the case, if the object at far away from 5 to 6 cm distance then the photodiode will not able to detect it. This is the same case when infrared ray bump to the black surface whatever it is near to 5 to 6 cm. The infrared ray can be absorbed by the black color and it will not reflect back. And it will sense like n
With the help of this property of the IR sensor, we can easily detect the black line path. We can control the movement of the line follower car robot automatically.
Basic Idea of Implementation
Our Automatic car robot movement defines in three directions to follow the black line.
- Move Forward
- Move Left
- Move Right
For all these movements of the car robot, we will use two IR sensors. The Left IR sensor will control the left turn and the right IR sensor will control the right turn movement of the car robot.
Let me explain to you one by one,
When both IR sensors are detecting the surface, it means that the black line is exactly between the IR sensors. Then the both IR sensor will produce LOW( 0 ) at the output pin(OUT). We will give the command to go the forward direction.
When the left IR sensor is detecting no object, it means that the left IR sensor is trying to cross the black line. Then the left side IR sensor will produce HIGH( 1 ) at the output pin. So, we have to give a command to take a left turn until both sensors are not detecting the surface.
It can be also possible that the right IR sensor is detecting no object, it means that the right IR sensor is trying to cross the black line. Then the right side IR sensor will produce HIGH( 1 ) at the output pin. So, we have to give a command to take a right turn until both sensors are not detecting the surface.
Look at the flowchart which is describing the overall flow of the control of the automatic line follower car robot.
I hope you have understood the idea of the implementation of building a black line follower robot. Now you can try to write the code by yourself. Still, I’m giving you my code.
You can download the code from here,
Yes, maybe my code is not fully optimized but it will give you the basic idea. You can code your own and you can include other functions in the automatic line follower car robot as well.
I hope you have learned something new.