Notes
Notes
1. Arduino Uno
• Theory: Acts as the brain of the robot, processing inputs from sensors and
controlling the motors based on the programmed logic.
• Details: A dual H-bridge motor driver that allows control of the speed and direction
of two DC motors.
• Theory: Converts low-power control signals from the Arduino into higher-power
signals to drive the motors. It can control the direction and speed of the motors by
varying the voltage and polarity.
3. IR Sensor Modules
• Details: Infrared sensors that consist of an IR LED and a photodiode. They detect
the presence of a line by measuring the reflected IR light.
• Theory: Used to detect the line on the ground. When the sensor is over a white
surface, the IR light is reflected back to the photodiode, indicating the presence of
the line.
4. DC Motors
• Details: Electric motors that convert electrical energy into mechanical energy to
drive the wheels.
• Theory: Provide the necessary movement for the robot. The speed and direction of
the motors are controlled by the motor driver based on the signals from the Arduino.
5. Wheels
• Theory: Enable the robot to move. The rotation of the wheels is controlled by the
motors.
6. Caster Wheel
• Details: A small, freely rotating wheel used for balance.
• Theory: Provides stability and balance to the robot, allowing it to turn smoothly.
7. Chassis
• Details: The base frame of the robot where all components are mounted.
• Theory: Provides a structure to hold all the components together and maintain the
robot’s form.
8. Battery Pack
• Theory: Supplies the necessary electrical energy to the Arduino, motor driver, and
motors.
9. Jumper Wires
• Theory: Allows for easy and temporary connections during the testing phase.
These components work together to create a functional line follower robot. The Arduino
processes the input from the IR sensors and sends control signals to the motor driver,
which in turn drives the motors to follow the line. The chassis, wheels, and caster wheel
provide the physical structure and movement capabilities.
Step-by-Step Instructions
Step 1: Assemble the Chassis
1. Mount the Motors: Attach the DC motors to the chassis using screws.
2. Attach the Wheels: Fix the wheels onto the motor shafts.
3. Add the Caster Wheel: Attach the caster wheel to the front or back of the chassis
for balance.
Step 2: Mount the Electronics
1. Place the Arduino Uno: Secure the Arduino board onto the chassis.
2. Attach the Motor Driver: Mount the L298N motor driver module near the Arduino.
Step 3: Connect the Motors to the Motor Driver
1. Motor Connections:
o Connect the left motor to the OUT1 and OUT2 terminals of the L298N.
o Connect the right motor to the OUT3 and OUT4 terminals of the L298N.
Step 4 :
1. Sensor Placement: Attach the IR sensors to the front of the chassis, facing
downwards.
2. Sensor Connections:
o Connect the VCC and GND pins of both IR sensors to the 5V and GND pins
on the Arduino.
o Connect the output pin of the left IR sensor to digital pin 2 on the Arduino.
o Connect the output pin of the right IR sensor to digital pin 3 on the Arduino.
Step 5: Wire the Motor Driver to the Arduino
1. Power Connections:
o Connect the 12V and GND pins of the L298N to the battery pack.
2. Control Connections:
o Connect IN1 and IN2 of the L298N to digital pins 8 and 9 on the Arduino (for
the left motor).
o Connect IN3 and IN4 of the L298N to digital pins 10 and 11 on the Arduino
(for the right motor).
o Connect the ENA and ENB pins of the L298N to the 5V pin on the Arduino (or
use PWM pins for speed control).
Step 6: Power Up and Upload Code
1. Power the System: Connect the battery pack to the Arduino and motor driver.
2. Upload the Code: Write and upload the line-following code to the Arduino. Here’s a
simple example:
int leftSensor = 2;
int rightSensor = 3;
int leftMotorForward = 8;
digitalWrite(rightMotorForward, HIGH);
int leftMotorBackward = 9;
digitalWrite(rightMotorBackward, LOW);
int rightMotorForward = 10;
} else if (leftState == HIGH && rightState == LOW)
int rightMotorBackward = 11; {
// Turn right
void setup() { digitalWrite(leftMotorForward, LOW);
pinMode(leftSensor, INPUT); digitalWrite(leftMotorBackward, LOW);
pinMode(rightSensor, INPUT); digitalWrite(rightMotorForward, HIGH);
pinMode(leftMotorForward, OUTPUT); digitalWrite(rightMotorBackward, LOW);
pinMode(leftMotorBackward, OUTPUT); } else if (leftState == LOW && rightState == HIGH)
pinMode(rightMotorForward, OUTPUT); {
} digitalWrite(leftMotorForward, HIGH);
digitalWrite(leftMotorBackward, LOW);
// Stop
}
1Variable Declarations:
o leftSensor and rightSensor: These are the pins connected to the left and right
sensors.
2. Setup Function:
3. Loop Function:
o Conditions:
▪ Both sensors LOW: Move forward by setting the forward pins of both motors
to HIGH and the backward pins to LOW.
▪ Left sensor HIGH, Right sensor LOW: Turn right by stopping the left motor
and running the right motor forward.
▪ Left sensor LOW, Right sensor HIGH: Turn left by running the left motor
forward and stopping the right motor.
▪ Both sensors HIGH: Stop by setting all motor control pins to LOW.
This code allows the robot to navigate based on the sensor inputs, moving forward, turning
left or right, or stopping as needed. If you have any more questions or need further
clarification, feel free to ask!
4of30