WELCOME
RESPECTED JUDGES
TO OUR PRSENTATION
Overview of Line Follower Robot
(Key Points)
A Line Follower Robot is a robotic vehicle that follows a specific line or path.
It uses infrared (IR) sensors to detect the line and moves accordingly.
The robot can move forward, turn, and stop based on the sensor inputs.
It requires a microcontroller (e.g., Arduino), motor driver (e.g., L298N), sensors, and motors to
function.
The primary goal is to keep the robot following the line without deviating from it.
IR SENSOR
1 L298N Motor Driver: Controls two motors, enabling speed
and direction control.
2 Arduino Uno: Processes input from sensors and sends commands to the
motor driver.
3. Rechargeable Battery: Powers the robot for autonomous movement.
4. Mini Breadboard: Provides easy prototyping and connections.
5. 4-Wheel Chassis: Supports motors and ensures stability.
6. 4 Motors: Enable forward, backward, and turning movements.
7. Connecting Wires: Link components for electrical continuity.
8. Battery Holders: Securely hold and connect batteries.
9. MHIV IR Sensors with CAP: Detect the line and guide the robot.
Introduction to L298N Motor
Driver
• The L298N is an H-Bridge motor driver used to control DC motors and
stepper motors. It can handle motor voltages from 5V to 46V,
supporting up to 2A per channel.
• It’s widely used in robotics, automation, and various motor control
applications.
Key Features of L298N
- Dual H-Bridge configuration for motor control.
- Supports DC motors and stepper motors.
- Voltage range from 5V to 46V.
- Up to 2A current per motor.
- PWM control for speed and direction.
- Built-in over-temperature and overload protection.
Pinout Details
• - IN1, IN2, IN3, IN4: Control motor direction.
• - ENA, ENB: Enable motors and control speed with PWM.
• - Vcc: Motor supply voltage (5V to 46V).
• - GND: Ground connection.
• - OUT1, OUT2, OUT3, OUT4: Motor connections.
Applications of L298N
- Robotics: Control motors in mobile robots, line-following robots, etc.
- Automated Systems: Conveyor belts, elevators, etc.
- DIY Projects: Arduino-based projects, simple motor drivers, etc.
- Stepper Motors: Used in CNC machines and 3D printers.
Summary
• The L298N Motor Driver is a versatile and
powerful motor driver used in various
applications like robotics, automation, and
motor control.
• It supports both DC motors and stepper motors,
with the ability to control speed and direction
using PWM.
Introduction to Arduino Uno
The Arduino Uno is an open-
source microcontroller board
based on the ATmega328P.
It is commonly used in DIY
projects, robotics, and
automation systems. It
features digital and analog
input/output pins and supports
various sensors and actuators.
Key Features of Arduino Uno
- Microcontroller: ATmega328P
- Operating Voltage: 5V
- Digital I/O Pins: 14 (6 PWM outputs)
- Analog Input Pins: 6
- Flash Memory: 32KB (0.5KB used by bootloader)
- Clock Speed: 16 MHz
- USB interface for programming and serial communication
Pinout Details
- Digital Pins: Used for input and
output, 14 in total
- PWM Pins: 6 pins (Pin 3, 5, 6, 9, 10,
11)
- Analog Pins: 6 pins (A0 to A5)
- 5V and 3.3V Pins: Provide power
for external components
- GND Pins: Ground connection
- Reset Pin: To reset the board
manually
Common Applications
- Robotics: Control servos, motors, sensors, etc.
- Home Automation: Automate lighting, temperature control, security systems
- Projects: Build smart devices and connect them to the internet
- Prototyping: Quick development of electronic projects
- Wearables: Build wearable electronics like health trackers
Summary
The Arduino Uno is an
easy-to-use and versatile
microcontroller board.
It allows for rapid
prototyping and is widely
used in educational
projects, DIY electronics,
and embedded systems.
2MHIV IR Sensor with CAP (Key
The 2MHIV IR sensor with CAP is
Points)
used for line-following robots.
It detects obstacles and tracks the
line by emitting infrared light and
receiving the reflected light.
The sensor includes both an IR LED
for emission and a photodiode for
detection.
The CAP(capacitor) helps stabilize
the sensor's readings by filtering
noise from the signals.
The sensor sends output signals to
the Arduino, which uses this data to
control the robot's movement.
2MHIV IR Sensor with CAP
(Detailed Explanation)
The 2MHIV IR sensor is used to detect lines on the floor by emitting infrared light .
When the light hits a surface, it reflects back to the photodiode for detection.
The CAP (capacitor) filters electrical noise and smooths the signal, ensuring stable sensor performance.
It can differentiate between dark and light surfaces (e.g., black line on a white surface).
The sensor sends digital output to the Arduino (HIGH or LOW), which helps control the motors based on the
line position.
The sensor typically has multiple detectors for improved accuracy and faster line-following response .
4-Wheel Chassis (Key Points)
The 4-wheel chassis provides the base
structure for mounting the robot's
components.
It consists of four wheels that offer stability
and allow movement on flat surfaces.
The chassis is typically made from
lightweight materials such as plastic or
metal.
It has mounting slots for attaching the
motor driver, Arduino, sensors, and wheels.
The chassis design allows for easy assembly
and provides a stable platform for the
robot.
4-Wheel Chassis (Detailed
Explanation)
The 4-wheel chassis serves as the foundation for the robot, ensuring stability.
• The chassis houses all major components like the motors, Arduino, and IR sensors, preventing them from shifting
during operation.
• It is usually designed to accommodate DC motors and has specific slots for mounting them.
• The lightweight structure ensures the robot can move quickly and efficiently, while the four wheels provide
balanced movement.
• The chassis material can be plastic, acrylic, or metal, and is selected based on the desired weight and durability.
• Proper placement of components on the chassis helps to maintain the robot's balance and prevent tipping.
4 Motors(key points)
The robot uses 4 motors to drive the
wheels and enable movement.
These motors are typically DC motors,
which provide reliable rotational motion.
Motors are connected to the chassis and
allow the robot to turn, move forward, and
reverse.
The motors' speed and direction are
controlled by the Arduino via the motor
driver (L298N).
The motors can be powered using the
same battery supply as the Arduino.
4 Motors (Detailed Explanation)
The DC motors in the robot are connected to the wheels, allowing for smooth and consistent
motion.
Each motor has a specific direction of rotation, which is controlled by the Arduino using the L298N
motor driver.
The motor driver sends signals to the motors, allowing the robot to follow commands like moving
forward or turning left/right.
The speed of the motors is controlled by adjusting the power supplied by the battery holder.
By varying the motor speeds and direction, the robot can maneuver effectively while following a
line or avoiding obstacles.
Connecting Wires
Connecting wires are
essential for linking
the components
together.
They transfer
Wire length must power and signals
be appropriate to between the
avoid tangled or Arduino, motor
loose connections. driver, sensors,
and motors.
Proper wire
Color-coding wires
management is
helps identify
important to avoid
positive and
interference or
negative
disconnections
connections easily.
during operation.
Battery Holder
The battery holder provides the necessary power to run the robot.
It typically holds two AA or 18650 batteries in series to provide a combined voltage of
7.4V.
The holder connects to both the Arduino and motor driver to power the entire robot.
A switch on the battery holder allows the robot to be powered on and off easily.
Battery life is crucial, and selecting the right capacity is important for long-term operation.
Step by Step
Explanation of Line
Follower Robot Code
Line by Line Breakdown of the Arduino Code
Motor Pins Declaration
• The following lines declare the motor control pins for the left and right
motors:
• const int IN1 = 9; // Left motor forward
• const int IN2 = 8; // Left motor backward
• const int IN3 = 7; // Right motor forward
• const int IN4 = 6; // Right motor backward
• • IN1, IN2 control the left motor.
• • IN3, IN4 control the right motor.
• These pins allow the Arduino to control the rotation of both motors in both
directions.
Sensor Pins Declaration
• The following lines define the sensor pins connected to the infrared
sensors:
• const int leftSensorPin = A0; // Left sensor connected to A0
• const int rightSensorPin = A1; // Right sensor connected to A1
• • The left sensor is connected to A0 pin.
• • The right sensor is connected to A1 pin.
• These sensors will detect the presence of the black line on the
surface.
PID Variables Declaration
• The next lines define the PID control parameters:
• const int Kp = 50; // Proportional gain (multiplied by 100 for integer
math)
• const int Ki = 10; // Integral gain (multiplied by 100 for integer math)
• const int Kd = 5; // Derivative gain (multiplied by 100 for integer math)
• • Kp, Ki, Kd are the constants that will affect how the robot adjusts its
movement.
• • These constants help balance the robot’s motion to correct its path.
• • Proportional (Kp) controls the reaction to current errors, Integral (Ki)
controls past errors, and Derivative (Kd) anticipates future errors.
PID Variables Initialization
• The following lines initialize variables to store PID data:
• int previous Error = 0;
• int integral = 0;
• int error = 0;
• int output = 0;
• Previous Error stores the previous error value for calculating the derivative.
• integral stores the accumulated error to address persistent discrepancies.
• error is the difference between the left and right sensors, used to adjust the
motors.
• Output holds the final PID result that will be used to control the motors.
Setup Function
• The setup() function runs once when the robot is powered on:
• pinMode(IN1, OUTPUT);
• pinMode(IN2, OUTPUT);
• pinMode(IN3, OUTPUT);
• pinMode(IN4, OUTPUT);
• pinMode(leftSensorPin, INPUT);
• pinMode(rightSensorPin, INPUT);
• • This sets the motor control pins (IN1, IN2, IN3, IN4) to OUTPUT mode.
• • This sets the sensor pins (leftSensorPin, rightSensorPin) to INPUT mode.
• The robot is ready to begin reading sensor data and controlling the motors.
Loop Function
• The loop() function runs continuously after setup:
• int leftSensor = analogRead(leftSensorPin);
• int rightSensor = analogRead(rightSensorPin);
• It reads the analog values from the left and right sensors.
• The sensor values help determine if the robot is on the line or off the
line.
Sensor Thresholding
• We normalize the sensor values to either 0 or 1 to detect the line:
• int leftLine = (leftSensor > 500) ? 1 : 0;
• int rightLine = (rightSensor > 500) ? 1 : 0;
• • A value greater than 500 indicates the sensor detects a black line
(1).
• • A value less than or equal to 500 indicates no line detected (0).
Error Calculation
• The error is calculated as the difference between the left and right
sensors:
• error = leftLine - rightLine;
• • This calculates how far the robot is from the center of the line.
• • If error = 0, the robot is on the line. Positive or negative error
indicates the robot needs to turn.
PID Control
• PID control is applied to the error to adjust the motor speeds:
• integral += error;
• int derivative = error – previous Error;
• output = Kp error + Ki integral + Kd derivative;
• • The integral and derivative values are updated to adjust the robot’s
path more accurately.
• • The final output determines how the motors should adjust to keep
the robot following the line.
Motor Speed Adjustment
• The setMotorSpeeds() function adjusts the motor speeds:
• if (output > 0) {
• setMotorSpeeds(255 - (output / 100), 255);
• }
• else if (output < 0) {
• setMotorSpeeds(255, 255 + (output / 100));
• }
• else {
• setMotorSpeeds(255, 255);
• }
• • The robot adjusts the speed based on the PID output.
• • Positive output turns the robot left, negative output turns it right, and zero keeps it straight.
Storing Previous Error
• Store the current error value for use in the next loop:
• previousError = error;
• The previous error is saved to calculate the derivative value for the
next iteration.
Loop Delay
• The delay ensures smooth control by giving time for sensor readings
and motor adjustment:
• delay(20);
• • This delay of 20 milliseconds ensures the robot responds quickly but
smoothly.
Stop Motors Function
• The stopMotors() function stops the motors by setting all control pins
to 0:
• analogWrite(IN1, 0);
• analogWrite(IN2, 0);
• analogWrite(IN3, 0);
• analogWrite(IN4, 0);
• • This function ensures that the robot stops when required.
THANK YOU
RESPECTED JUDGES
FOR LISTENING TO OUR PRESENTATION