A robot that chases a torch beam using two light sensors.
Built and tested by Anju.A · Industrial Robotics Institute

An autonomous robot that moves towards light. Two LDR light-sensor modules sit at the front left and right; the Arduino compares them and turns towards the brighter side, so the robot follows a torch around the room.
| Component | Qty |
|---|---|
| Arduino Uno | 1 |
| LDR Sensor Modules | 2 |
| L298N Motor Driver Module | 1 |
| BO Gear Motors | 2 |
| Robot Chassis | 1 |
| Wheels and Caster Wheel | 1 |
| 18650 Lithium Batteries | 2 |
| Battery Holder with Switch | 1 |
| Jumper Wires | As needed |
| From | Connect to |
|---|---|
| Left LDR VCC / GND | 5V / GND |
| Left LDR OUT | Pin 2 |
| Right LDR VCC / GND | 5V / GND |
| Right LDR OUT | Pin 3 |
| L298N IN1 | A0 |
| L298N IN2 | A1 |
| L298N IN3 | A2 |
| L298N IN4 | A3 |
| Battery + | L298N 12V |
| Battery − | L298N GND |
| Arduino GND | L298N GND |
Complete, tested Arduino C++ code for this project. Copy it into Arduino IDE and upload it to the Arduino Uno.
int leftSensor = 2;
int rightSensor = 3;
int LM1 = A0;
int LM2 = A1;
int RM1 = A2;
int RM2 = A3;
void forward() { digitalWrite(LM1, HIGH); digitalWrite(LM2, LOW); digitalWrite(RM1, HIGH); digitalWrite(RM2, LOW); }
void left() { digitalWrite(LM1, LOW); digitalWrite(LM2, HIGH); digitalWrite(RM1, HIGH); digitalWrite(RM2, LOW); }
void right() { digitalWrite(LM1, HIGH); digitalWrite(LM2, LOW); digitalWrite(RM1, LOW); digitalWrite(RM2, HIGH); }
void stopRobot() { digitalWrite(LM1, LOW); digitalWrite(LM2, LOW); digitalWrite(RM1, LOW); digitalWrite(RM2, LOW); }
void setup()
{
pinMode(leftSensor, INPUT);
pinMode(rightSensor, INPUT);
pinMode(LM1, OUTPUT);
pinMode(LM2, OUTPUT);
pinMode(RM1, OUTPUT);
pinMode(RM2, OUTPUT);
}
void loop()
{
int leftValue = digitalRead(leftSensor);
int rightValue = digitalRead(rightSensor);
if (leftValue == HIGH && rightValue == HIGH) forward();
else if (leftValue == LOW && rightValue == HIGH) left();
else if (leftValue == HIGH && rightValue == LOW) right();
else stopRobot();
}An autonomous robot that moves towards light. Two LDR light-sensor modules sit at the front left and right; the Arduino compares them and turns towards the brighter side, so the robot follows a torch around the room.
You need: Arduino Uno (1), LDR Sensor Modules (2), L298N Motor Driver Module (1), BO Gear Motors (2), Robot Chassis (1), Wheels and Caster Wheel (1), 18650 Lithium Batteries (2), Battery Holder with Switch (1), Jumper Wires. Software: Arduino IDE.
Yes. It is rated beginner and takes about 1–2 hours to build, using the Arduino Uno. The guide on this page explains every connection and step.
The complete, tested Arduino C++ code is free on this page. Copy it into Arduino IDE and upload it to the board.
Yes. IRI sells a kit with the parts for this project (PRJ-101). Message IRI on WhatsApp at +91 86060 82634 for the kit price and delivery details.