Summary
Building a robot that can respond to its surroundings is one of the most exciting milestones for anyone learning Arduino. A light-following robot is an excellent beginner project because it combines sensors, motor control, and basic programming into a single build. Instead of following a predefined path, the robot continuously detects the brightest light source and steers towards it.
This project introduces several core robotics concepts, including analog sensor readings, differential motor control, and decision-making using Arduino. The best part is that it can be assembled in just a few hours using commonly available components, making it an ideal weekend project for students, hobbyists, and STEM learners.
In this tutorial, we'll build a simple two-wheel light-following robot using an Arduino Uno, two Light Dependent Resistors (LDRs), an L298N motor driver, and two DC geared motors.

How Does a Light Following Robot Work?
A light-following robot uses two LDR sensors mounted on the front of the robot.
Each sensor continuously measures the amount of light falling on it.
The Arduino compares the values from both sensors and adjusts the motors accordingly.
The decision-making process is simple:
-
If both sensors receive equal light, the robot moves forward.
-
If the left sensor detects more light, the robot turns left.
-
If the right sensor detects more light, the robot turns right.
-
If both sensors detect very little light, the robot stops or continues searching.
This method is known as differential steering and is widely used in beginner robotics.
Components and Supplies
Components Required
You'll need the following components.
Electronics
-
2 × DC Geared Motors
-
2 × Wheels
-
Castor Wheel
-
2 × LDR Sensors
-
2 × 10kΩ Resistors
-
Battery Holder (2S Li-ion or 6×AA)
-
Breadboard (optional)
-
Power Switch
Understanding the Components
Arduino Uno
The Arduino reads the sensor values and decides how the motors should move.
It acts as the brain of the robot.
LDR Sensors
An LDR (Light Dependent Resistor) changes its resistance depending on light intensity.
-
Bright light → Lower resistance
-
Darkness → Higher resistance
Since the Arduino cannot directly measure resistance, each LDR is connected as a voltage divider using a 10kΩ resistor.
The Arduino then reads the voltage using its analog inputs.
L298N Motor Driver
Arduino GPIO pins cannot directly drive DC motors.
The L298N motor driver receives low-power control signals from Arduino and supplies sufficient current to the motors.
It allows each motor to:
-
Rotate forward
-
Rotate backward
-
Stop

Circuit Connections
Left LDR
-
One terminal → 5V
-
Other terminal → A0
-
10kΩ resistor between A0 and GND
Right LDR
-
One terminal → 5V
-
Other terminal → A1
-
10kΩ resistor between A1 and GND
L298N Connections
Arduino to Motor Driver
-
IN1 → Pin 8
-
IN2 → Pin 9
-
IN3 → Pin 10
-
IN4 → Pin 11
-
ENA → Pin 5 (PWM)
-
ENB → Pin 6 (PWM)
Motors
-
Motor A → Left motor
-
Motor B → Right motor
Power
-
Battery Positive → 12V terminal
-
Battery Negative → GND
-
Connect Arduino GND to Motor Driver GND.
This common ground is essential for proper operation.
Building the Robot
Step 1: Assemble the Chassis
Mount the two DC motors onto the robot chassis.
Attach both wheels.
Install the castor wheel at the front or rear depending on your chassis design.
Ensure the wheels rotate freely.
Step 2: Mount the Arduino
Fix the Arduino onto the top of the chassis using spacers or double-sided tape.
Leave enough room for the battery pack and motor driver.
Step 3: Install the Motor Driver
Place the L298N close to the motors.
Shorter motor wires reduce electrical noise.
Step 4: Install the LDR Sensors
Position the two LDRs approximately 6–8 cm apart at the front of the robot.
To improve directional sensing, place a small divider between the sensors using black cardboard or plastic.
This prevents one sensor from receiving light intended for the other.
Programming Logic
The Arduino repeatedly performs four simple steps.
Step 1
Read both analog sensors.
Left Sensor
↓
Analog Value
Right Sensor
↓
Analog Value
Step 2
Compare the readings.
If:
Left > Right
↓
Turn Left
If:
Right > Left
↓
Turn Right
If:
Both Nearly Equal
↓
Move Forward
Step 3
Drive the motors.
Motor directions determine the robot's movement.
Forward
-
Left Motor → Forward
-
Right Motor → Forward
Turn Left
-
Left Motor → Slow
-
Right Motor → Fast
Turn Right
-
Left Motor → Fast
-
Right Motor → Slow
Step 4
Repeat continuously.
The robot constantly adjusts its direction as the light source moves.
Here's the full code for the Project on Github: Line Following Robot
Calibrating the Robot
Calibration is important because different LDRs rarely produce identical readings.
Open the Serial Monitor and observe both analog values.
Example:
Left : 540
Right : 520
Instead of comparing exact values, introduce a small tolerance.
For example:
Difference < 20
↓
Move Straight
Difference > 20
↓
Turn
This prevents unnecessary steering caused by minor fluctuations.
Testing the Robot
Place the robot on a smooth floor.
Turn on the battery.
Use a flashlight as the light source.
Light in Front
Expected result:
Robot moves forward.
Light on Left
Expected result:
Robot turns left until both sensors receive similar light.
Light on Right
Expected result:
Robot turns right.
No Light
Expected result:
Robot either stops or continues searching depending on your program.
Common Problems
Robot Spins in Circles
Usually caused by:
-
Motor polarity reversed
-
Incorrect motor driver wiring
Swap the motor terminals if necessary.
Robot Moves Away from Light
The LDR logic is reversed.
Simply swap the comparison conditions inside the Arduino program.
Motors Do Not Move
Check:
-
Battery voltage
-
Common ground
-
Motor driver enable pins
-
Motor driver wiring
Robot Oscillates Continuously
Reduce sensor sensitivity by increasing the comparison threshold.
This produces smoother movement.

Where to Buy Components in India
Most of the components required for this project are readily available.
Robocraze offers Arduino Uno Boards, L298N Motor Drivers, LDR Sensors, DC geared motors, robot chassis kits, batteries, jumper wires, breadboards, and other robotics components required to build this project. Purchasing compatible components from a single supplier makes assembly much easier and reduces compatibility issues.
Final Thoughts
Building a light-following robot is an excellent introduction to practical robotics because it combines sensing, motor control, and real-time decision-making into a single project. The robot reacts to changes in its environment without requiring complicated algorithms, making it an ideal learning platform for beginners.
For anyone interested in building a light follower robot India project, this tutorial provides a solid foundation in Arduino programming and robotics. Once you've mastered this build, you can confidently move on to more advanced projects such as obstacle-avoiding robots, Bluetooth-controlled vehicles, and autonomous navigation systems.






